nginx wordpress permalinks Month and name

在nginx下搭建wordpress 并使用permalinks 功能, 设置为  Month and name

 

Month and name       http://www.goog.cn/blog/index.php/2010/09/sample-post/

 

 

 

在这个方式下访问不正常,遂google,答案如下

 

http://www.cnblogs.com/HCOONa/archive/2010/08/22/enable-permalink-for-wordpress-3-in-nginx.html

安装完成后准备启用友好形式的永久链接,但是经过种种尝试和查资料后,都不能成功。

Nginx没有Apache特有的mod_rewrite,因此不能由WordPress自动配置。

查资料时发现网上流传广泛的解决方案都不管用。

 

下面给出我的解决方案。

首先参照Apache2的.htaccess文件:
view source
print?
1	RewriteEngine On
2	RewriteBase /wordpress/
3	RewriteRule ^index\.php$ - [L]
4	 
5	RewriteCond %{REQUEST_FILENAME} !-f [OR]
6	RewriteCond %{REQUEST_FILENAME} !-d
7	RewriteRule . /wordpress/index.php [L]

翻译成Nginx的rewrite规则如下:

 
view source
print?
1	location /wordpress/ {
2	    rewrite ^index\.php$ - last;
3	 
4	    if ( !-e $request_filename ) {
5	            rewrite . /wordpress/index.php last;
6	    }
7	}

已经经过实践验证了。:-)

 

 

在wordpress文件目录下

 vi .htaccess   可以看到

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

 

if ( !-e $request_filename ) {
5	            rewrite . /wordpress/index.php last;
6	    }

就相当于翻译了一下apache的规则

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值