nginx下设置wordpress的永久链接(Permalinks)
Mar
18
nginx下设置wordpress的永久链接(Permalinks)
网站挂出来后,看到文章的链接都是?p=xx
虽然不影响使用,但是总感觉很不爽,也不利于搜索引擎的收录?,还好wordpress有个设置永久链接,也就是Permalinks的东东 ^_^
进入后台–>设置–>永久链接,我使用的是自定义结构
/%year%/%monthnum%/%day%/%postname%/
此处的postname还需要修改,最好是使用文章标题的英文别名,中文的不利于搜索引擎收录,方法是在写日志的时候填写好post slug也即“日志缩略名”(右边有一排关于日志的东东)
点击更新
刷新网站后,咦?怎么都打不开文章了?
应该是rewrite没有起作用,突然想起我使用的web sever是nginx ,没有.htaccess文件 -_-’!虚惊一场
?我的nginx的rewrite rule如下:
??????? location / {
??????????? 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;
??????????? }
??????? }
注意最好不要使用404页面跳转的方式,否则你网站上的原创文章会被搜索引擎拔毛个精光,最后会只剩下个首页。。。。
顺便附上apache的rewrite规则
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


















No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URI
Leave a comment
If you want to leave a feedback to this post or to some other user´s comment, simply fill out the form below.