Nginx支持WordPress3.0.1的永久链接(Permalink)

mac2022-06-30  24

我最近准备使用Nginx+php-fpm搭建WordPress平台。

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

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

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

 

下面给出我的解决方案。

首先参照Apache2的.htaccess文件:

RewriteEngine On RewriteBase /wordpress/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L]

翻译成Nginx的rewrite规则如下:

location /wordpress/ { rewrite ^index\.php$ - last; if ( !-e $request_filename ) { rewrite . /wordpress/index.php last; } }

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

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

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)