创建不受WordPress影响的子文件夹

时间:2014-01-10 15:04:48

标签: wordpress apache .htaccess mod-rewrite http-status-code-404

我在root中安装了一个WordPress站点。我在子文件夹/商店中为此站点添加了一个在线商店。在/ shop文件夹中是一个index.php文件和这个.htaccess文件:

#/shop/.htaccess
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?arg1=$1 [L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?arg1=$1&arg2=$2 [L]

一些示例有效网址为:

http://www.mysite.com/shop/
http://www.mysite.com/shop/clothes
http://www.mysite.com/shop/shoes
http://www.mysite.com/shop/hats

这些网址显示正常,但标题为404 会导致Google出现问题。

这是请求标题:

GET /shop/clothes/ HTTP/1.1
Host: www.mysite.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://www.mysite.com/shop/
Cookie: __utma=152555369.2028364656.1389216381.1389279043.1389294490.4; __utmz=152555369.1389216381.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); wp-settings-1=editor%3Dtinymce%26hidetb%3D1%26libraryContent%3Dbrowse%26urlbutton%3Dnone%26wplink%3D1; wp-settings-time-1=1389277270; PHPSESSID=2df7073e57934fd781ab27c1c7b74245; __utmb=152555369.34.10.1389294490; __utmc=152555369; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_b2aba7eb0409bbc11fbbc4c2403dc2dc=admin%7C1389471226%7Cc07f299f80fe0ac1b15598636b08f66f
X-LogDigger-CliVer: client-firefox 2.1.7
X-LogDigger: logme=0&reqid=f7a4f2ac-3cfc-4a63-94e6-0b9233c7dfe6&
Connection: keep-alive

以下是响应标题:

HTTP/1.1 404 Not Found
Date: Thu, 09 Jan 2014 20:21:23 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_perl/2.0.5 Perl/v5.8.8
X-Powered-By: PHP/5.3.13
X-Pingback: http://www.mysite.com/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Content-Length: 14381

在我的/shop/index.php文件中,我尝试手动输出状态为200的标题,但它没有解决问题。

我尝试将以下内容添加到根.htaccess文件(WordPress)中,但它没有用:

ErrorDocument 401 default

在根.htaccess文件(WordPress)中,我尝试在WordPress的RewriteRules之前,之后和之内添加这些命令,但我仍然得到404标题:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/shop/(.*)$
RewriteRule ^.*$ - [L]

/ shop文件夹和子文件夹具有0755权限,文件的0644与WordPress安装具有相同的所有者/组。

感谢任何帮助。感谢。

1 个答案:

答案 0 :(得分:0)

测试WP是否确实导致它:

  • 您可以将WP .htaccess重命名为其他内容,然后检查是否仍然可以获得404标题。

如果WP .htaccess仍然出现404错误,则很可能是由/shop/文件夹中的规则/代码引起的。