WordPress博客程序URL静态化
WordPress博客程序URL静态化
打开wordpress后台管理界面:设置-固定链接-自定义结构中输入:/archives/%post_id%.html - 保存。
[[email protected] ~]# cd /application/nginx/conf/extra/
[[email protected] extra]# vim blog.conf #编辑nginx的blog的配置文件
server {
listen 80;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.php index.html index.htm;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
rewrite (.*) /index.php;
}
}
location ~ .*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
或者添加以下代码:
location / {
try files $uri $uri/ /index.php?q=$uri&$args;<br></span>
}
[[email protected] extra]# /application/nginx/sbin/nginx -t #检查语法
[[email protected] extra]# /application/nginx/sbin/nginx -s reload #平滑重启nginx
测试:写一篇博文测试