您的位置:首页 > 运维架构 > Nginx

Nginx配置Restful风格url

2016-03-03 23:09 585 查看
开始做seo的优化,当然牵扯到固定链接,wordpress提供多种类型的链接形式:

1234567/%year%/%monthnum%/%day%/%postname%//%year%/%monthnum%/%postname%//%year%/%monthnum%/%day%/%postname%.html/%year%/%monthnum%/%postname%.html/%category%/%postname%.html/%post_id%.html/%postname%/
我选择了/%postname%伪静态,虽然现在貌似没什么差别了,但还是该下吧。下面就出现了修改固定链接后,访问文章会出现404错误。wordpress官方给出了新的开启固定链接的方法,非常简单的。将下列代码粘贴到nginx的conf配置文件里。

1

2

3

4

location
/
{

try_files
$uri
$uri/
/index.php?$args;

}

rewrite
/wp-admin$
$scheme://$host$uri/
permanent;

接着重启nginx就可以正常访问了!!!

原文地址:http://wanshicheng.org/nginx%E9%85%8D%E7%BD%AErestful%E9%A3%8E%E6%A0%BCurl/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: