Win主机安装wordpress程序设置固定连接(伪静态)导致根目录部分文件无法访问的解决方法

wordpress通过安装ISAPI_Rewrite组件配置httpd.ini的伪静态规则:

# Defend your computer from some worm attacks
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /tag/(.*) /index\.php\?tag=$1
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /robots.txt /robots.txt [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]

根据提示# Defend your computer from some worm attacks
意思是为了抵御部分如蠕虫病毒进攻,所以把非 WordPress 文件设置为无法打开。
如果想打开某个文件只要在下面添加一条 RewriteRule 就能让你需要的文件正常访问
举个例子: 比如上传一个页面test.php,现在wordpress做好伪静态了,但是test.php无法访问,访问就直接跳到404了,
那伪静态规则文件里的代码就可以加入这样一行代码:RewriteRule /test.php /test.php [L]

# Defend your computer from some worm attacks
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /tag/(.*) /index\.php\?tag=$1
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /robots.txt  /robots.txt [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
RewriteRule /test.php /test.php [L]
RewriteRule /文件名 /文件名 [L]
RewriteRule /文件名 /文件名 [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]

把代码改成想打开的那个文件的文件名就可以了 有多个文件需要打开,就添加多条

有关本站文章版权声明如下:
若是原创文章,您转载时请注明出处和链接地址(URL);
若是转载的文章,您在转载时请注明原文的出处和链接地址(URL);
若是转载的文章涉侵您的版权,请及时留言告知。
THE END
分享
二维码
打赏
< <上一篇
下一篇>>
文章目录
关闭
目 录