正在加载...

一、nginx伪静态设置:

nginx下Wordpress固定链接的伪静态规则其实特别简单,在nginx配置文件nginx.conf的location段添加一行就OK。

1. 打开nginx配置文件:

# vim /etc/nginx/nginx.conf(此路径根据Linux版本与安装路径会有不同)

2. 在server容器中添加下面这几行

location /
{
try_files $uri $uri/ /index.php?q=$uri&$args;
}

3. 重新加载nginx配置文件

# /etc/init.d/nginx reload

完成设置。

二、apache伪静态设置:

1. 检查/etc/httpd/conf/httpd.conf中是否rewrite模块:
LoadModule rewrite_module libexec/mod_rewrite.so

2. 检查Apache是否开启.htaccess支持:
AllowOverride All(默认在httpd.conf文件的338行)

这部分详细配置如下:

<Directory "/var/www/html">
Options Includes ExecCGI FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</Directory>

修改完后重启apache生效。

: http://www.ha97.com/805.html

本文相关评论 - 才 12 条评论
阿弈
2010-09-06 19:29:59
Maxthon 3.0 Maxthon 3.0 Windows 7 Windows 7

刚刚按照你的伪静态规则设置了一下。成功了。谢谢啦!

2010-09-08 17:00:08
Firefox 3.0.6 Firefox 3.0.6 openSUSE openSUSE

不客气~~

2010-11-12 07:21:00
Google Chrome 8.0.556.0 Google Chrome 8.0.556.0 Windows 7 Windows 7

hi,我使用了vps和cos-html-cache以及inove主题,但是搜索不管用了,可以帮我写写静态化么?

2010-11-16 11:20:59
Firefox 3.6.9 Firefox 3.6.9 Red Hat Enterprise Linux 6 Red Hat Enterprise Linux 6

cos-html-cache这个插件我没用过,可能不一样~~

飞儿
2011-06-24 07:06:41
Google Chrome 10.0.634.0 Google Chrome 10.0.634.0 Windows XP Windows XP

您好,我按照您的设置,还是不对,是wordpress刚刚装好的

2011-07-03 12:22:33
Google Chrome 12.0.742.112 Google Chrome 12.0.742.112 Windows 7 Windows 7

可以的,你可能放错地方了!

2011-10-04 15:33:57
Google Chrome 13.0.782.112 Google Chrome 13.0.782.112 Windows 7 x64 Edition Windows 7 x64 Edition

设置成功,非常感谢!

2012-07-29 15:15:45
Sogou Explorer Sogou Explorer Windows 7 Windows 7

请问遇到过没有网页返回404很慢的情况呢?

就是访问一个不存在的页面,后台已经是404了。但是前台一直是等待服务器响应的状态。。

icaction
2012-10-04 01:27:30
Firefox 14.0.1 Firefox 14.0.1 Windows 7 x64 Edition Windows 7 x64 Edition

请教 如果wordpress要是放在子目录,怎么办呢?
例如 /home/wwwroot/www.xxx.com/blog

max
2012-10-08 01:27:37
Google Chrome 22.0.1229.79 Google Chrome 22.0.1229.79 Windows 7 x64 Edition Windows 7 x64 Edition

设置成功,谢谢啦!

2013-03-31 15:42:17
Firefox 19.0 Firefox 19.0 Ubuntu Ubuntu

帮我大忙啦.

2013-05-28 10:02:13
Google Chrome 26.0.1410.65 Google Chrome 26.0.1410.65 Mac OS X  10.7.5 Mac OS X 10.7.5

测试成功,但是不知道是什么原理?