首页 > 折腾WP > httpd.ini 配置导致根目录部分文件无法访问

httpd.ini 配置导致根目录部分文件无法访问

这个问题一直困扰我到现在,今天心血来潮做了一个 jQuery + css 的 Tooltips 效果(小闇那抄来的),想挂到根目录下的Demo文件夹下,打算以后就存放这样的演示独立页。

但问题是根目录下除了WordPress的文件,其他文件/文件夹都无法打开。一开始以为是插件的原因,关闭所有插件,依旧无法打开。于是我就怀疑是 url rewriter 的问题,检查了 httpd.ini 文件,刚开始不太懂,但慢慢被我琢磨出来了:

[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 /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]

上面说为了抵御部分病毒进攻,而把非 WordPress 文件设置为无法打开。所以只要在下面添加一条 RewriteRule 就能让你需要的文件/文件夹顺利访问:

RewriteRule /demo/(.*) /demo/$1 [L]

顺便说下,如果你使用 WLW 无法配置成功,也有可能是因为 url rewriter 配置文件问题,你可以看看 httpd.ini 或者 .htaccess 文件是否配置正确,如果是 httpd.ini,只要添加一句:

RewriteRule /xmlrpc.php /xmlrpc.php [L]
  1. Solo@ 2010.10.19 / 21:00| #11

    这个没看懂。

  2. 兵者帅@ 2010.11.16 / 21:08| #12

    iis 下httpd这样的写法,碰到数字开头的地址无法访问。不知道是为什么。还有汉字转成编码也不不行。默认的.htaccess都可以。这是为什么?

  3. luren@ 2010.11.17 / 21:19| #13

    @兵者帅
    数字开头是指?文件夹是数字?汉字编码是不行,所以我把固定链接改为英文,我也不知道什么原因,可能是win主机本身的原因吧,只能凑合着用吧

  4. 兵者帅@ 2010.11.17 / 21:26| #14

    分类别名,也就是路径了,不过文章和页面已经解决了,就是分类不行。

  5. luren@ 2010.11.18 / 18:44| #15

    @兵者帅
    哦,有空去研究下,呵呵

  6. 夏末の伤@ 2010.12.13 / 11:06| #16

    文件夹下的倒是可以了,但是文件还是不行,比如TXT和HTML都打不开。。。

  7. luren@ 2010.12.13 / 21:52| #17

    @夏末の伤
    如果是文件的话,加:
    RewriteRule /xx.txt /xx.txt [L]
    你再试试看

  8. 残阳@ 2011.01.20 / 23:28| #18

    我按照你说的设置后还是无法访问跟目录的文件 其他都正常

  9. luren@ 2011.01.22 / 23:09| #19

    @残阳
    你的主机是否是win主机?

评论提交中, 请稍候...