本文整理自网络,侵删。
众所周知,wordpress是基于php开发,在apache服务下运行是最优秀的。但是,国内仍然有很多主机上不能提供apache服务器,大多都是IIS环境。因此,导致wp在IIS环境下,出现很多问题,解决起来也比较麻烦。UISEO优化网也不小心使用了IIS。因此,在遇到的关于IIS环境造成的一系列问题,记录下来,帮助有同样痛苦的站长共同分享。本篇主要是关于IIS伪静态成功后造成的子目录和其他一些根目录的文件不能正常访问的问题。
近几日想给博客加上一些别的页面,自然要用到子目录。没想到访问所有非WP-开头的子目录内容都转到404页面去了。看样子WP还真有的高深莫测,令我丈二和尚摸不着头脑啊,后找了不少资料才基本解决此问题,方法是修改伪静态规则文件httpd.ini:
下载或者在线编辑httpd.ini文件,在原来规则中增加一条代码RewriteRule /tool/(.*) /tool/$1 [L],增加后完整规则如下(/tool/是二级目录名,具体名称是什么就写什么,注意是双斜杠):
编辑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 /favicon.ico /favicon.ico [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]
RewriteRule /sitemap.html /sitemap.html [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]
上面的内容是配置伪静态,以下是设置子目录访问配置代码
如果需要某个子目录(比如UISEO优化网需要增加pr子目录),则在# Rules to ensure that normal content gets through行下增加如下内容:
[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 /favicon.ico /favicon.ico [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]
RewriteRule /sitemap.html /sitemap.html [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]
上面的内容是配置伪静态,以下是设置子目录访问配置代码
如果需要某个子目录(比如UISEO优化网需要增加pr子目录),则在# Rules to ensure that normal content gets through行下增加如下内容:
代码如下:
RewriteRule /pr/(.*) /pr/$1 [L]
如果有多个子目录的话,也是可以的,设置几条这样的规则就行了。如:
RewriteRule /pr/(.*) /pr/$1 [L]
如果有多个子目录的话,也是可以的,设置几条这样的规则就行了。如:
代码如下:
RewriteRule /文件夹名1/(.*) /文件夹名1/$1 [L]
RewriteRule /文件夹名2/(.*) /文件夹名2/$1 [L]
RewriteRule /文件夹名3/(.*) /文件夹名3/$1 [L]
就这样,基本上可以解决此问题。或许还有更好的方法,继续摸索中……也欢迎大家共享。
如果是想访问根目录下的其他文件,比如验证文件html。则参考
RewriteRule /文件夹名1/(.*) /文件夹名1/$1 [L]
RewriteRule /文件夹名2/(.*) /文件夹名2/$1 [L]
RewriteRule /文件夹名3/(.*) /文件夹名3/$1 [L]
就这样,基本上可以解决此问题。或许还有更好的方法,继续摸索中……也欢迎大家共享。
如果是想访问根目录下的其他文件,比如验证文件html。则参考
代码如下:
RewriteRule /sitemap.xml /sitemap.xml [L]
只需将相应名称换成要访问的即可。
对于具体的语法,想更深入了解的,可以百度,也可以找本人。随时为大家无私奉献!
RewriteRule /sitemap.xml /sitemap.xml [L]
只需将相应名称换成要访问的即可。
对于具体的语法,想更深入了解的,可以百度,也可以找本人。随时为大家无私奉献!
标签:WordPress
相关阅读 >>
以wordpress为例讲解jquery美化页面title的方法
wordpress全局变量$wpdb初始化并声明为全局变量的方法
wordpress编辑器中添加链接功能自动加入nofollow的方法
文档格式转换大全:怎么把word文档转成pdf,wps文档转换成word
wordpress 3.0+菜单功能支持二级和n级菜单实现步骤
更多相关阅读请进入《wordpress》频道 >>
相关推荐
评论
管理员已关闭评论功能...
- 欢迎访问木庄网络博客
- 可复制:代码框内的文字。
- 方法:Ctrl+C。