lnmp博客偽靜態實踐完成
阿新 • • 發佈:2017-08-28
linux
lnmp博客偽靜態實踐完成
打開wordpress後臺管理界面:設置-固定鏈接-自定義結構中輸入:/archives/%post_id%.html
保存。
然後打開web01,vi /application/nginx/conf/extra/blog.conf輸入如下內容
[[email protected] ~]# cat /application/nginx/conf/extra/blog.conf 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; } }
(提示:把上圖中的
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;
}
用下面的
try files $uri $uri/ /index.php?q=$uri&$args;
替換,也可以達到預期效果。)
檢查nginx語法並平滑重啟
[[email protected] ~]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful [[email protected] ~]# /application/nginx/sbin/nginx -s reload
再次打開wordpress blog裏面的文章,發現網址已經變成了偽靜態了。
本文出自 “sandshell” 博客,請務必保留此出處http://sandshell.blog.51cto.com/9055959/1959761
lnmp博客偽靜態實踐完成