wordpress伪静态解决方法(2)利用httpd.ini文件

发表时间:2010-08-30 15:23:10

弄了个WordPress的网站,我本地做的好好的,但是,传到服务器上才发现,这个服务器不支持伪静态,开始用了404页面的方法,详细见
wordpress伪静态解决方法404–windows系统
但是呢,不是很稳定,我不知道是服务器的问题还是,这个方法的问题.这样就很不符合用户体验了。还是忍痛放弃了。
找了很多这个代码,差不多千篇一律的样子。下面我下列出来这个代码。
<?php
[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
?>把这段代码保存成httpd.ini文件,然后传到网站的根目录。测试后,发现效果还是不错的,设置永久链接,就随意设定了,跟Linux主机一样。
但是,我发现了一个其他的问题,它好像把很多的php都伪静态了,这样就导致了一些其他的东西不能用了,比如,我还安装了一个phpwind论坛程序,完全不能用了。
开始我没仔细看上面那段代码,细细琢磨一下之后,我又修改了一下这个httpd.ini文件,代码如下
<?php
[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /bbs/(.*) /bbs/$1 [L]
RewriteRule /phpmyadmin/(.*) /phpmyadmin/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
RewriteRule /unzip.php /unzip.php [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
?>你会发现,我增加了一些句子。
下面我来解释一下这些句子的作用。
RewriteRule /bbs/(.*) /bbs/$1 [L] 这句话呢,就是对bbs目录下的所有文件不进行伪静态。这里是我的论坛程序。
RewriteRule /phpmyadmin/(.*) /phpmyadmin/$1 [L] 这句话呢,就是对phpmyadmin目录下的所有文件不进行伪静态。
这个是一个管理MySQL的程序,有兴趣的朋友可以百度一下。
RewriteRule /unzip.php /unzip.php [L] 这句话,就更简单了,不伪静态unzip.php这个文件,这个文件是一个在线解压zip的页面,用起来不错。
这样一来,所有的问题都解决了。 

------分割线---------------------------------------

Tags: 伪静态 WordPress httpd.ini 论坛

留个脚印

点击我更换图片 (请输入验证码)

最新评论