配置网站伪静态
第一步:
修改nginx的配置文件:/etc/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location / {
root /applocation/wordpress;
index index.html index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
root /applocation/wordpress;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
第二步:
在wordpress上修改永久链接:
固定连接可以随意配置,
这里我选择的是文章名称,可以选择自定义结构,自定义结构中有许多的标签,具体如下:
- %year% 基于文章发布年份,比如2007
- %monthnum% 基于文章发布月份,比如05
- %day% 基于文章发布当日,比如28
- %hour% 基于文章发布小时数,比如15
- %minute% 基于文章发布分钟数,比如43
- %second% 基于文章发布秒数,比如33
- %postname% 基于文章的postname,其值为撰写时指定的缩略名,不指定缩略名时是文章标题
- %post_id% 基于文章post_id,比如423
- %category% 基于文章分类,子分类会处理成"分类/子分类"这种形式
- %author% 基于文章作者名
第三步:
重启nginx服务。
systemctl reload nginx
至此,我们的网站的伪静态就算配置好了。