有时候我们也会在网站的二级子目录中建立一个新的网站,在访问二级目录中就会自动跳转到首页,但是我们的wordpress在直接访问二级目录的时候返回的是404错误页面这很明显是找不到首页。
这里如果我们在IIS中就需要修改httpd.conf文件只要添加一句代码即可:
[code]RewriteRule /bbs/(.*) /bbs/$1 [L][/code]
bbs修改成为你们子目录的名称即可。
如果是linux需要修改httpd.ini文件。
一、wordpress博客一个子目录伪静态
下载或者在线编辑httpd.ini文件,在原来规则中增加一条代码RewriteRule /bbs/(.*) /bbs/$1 [L],增加后完整规则如下(/bbs/是二级目录名,具体名称是什么就写什么,注意是双斜杠):
[code][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 /bbs/(.*) /bbs/$1 [L]
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L][/code]
上面增加的这条规则意思就是访问“/bbs/”都会转到“bbs”这个二级目录,也就是说我们访问http://www.XXX.net/bbs/时就转到空间根目录下的bbs文件夹。
如果有多个子目录的话,也是可以的,设置几条这样的规则就行了。如:
RewriteRule /文件夹名1/(.*) /文件夹名1/$1 [L]
RewriteRule /文件夹名2/(.*) /文件夹名2/$1 [L]
RewriteRule /文件夹名3/(.*) /文件夹名3/$1 [L]
这就是windows主机下wordpress博客伪静态后子目录无法访问的解决。一般来说,windows主机下wordpress博客的路径访问不正常,都与伪静态有关,只要解决伪静态,访问也就没问题了。实在不清楚,或者测试出问题的,可以联系贵阳SEO解决。