我在使用 htaccess 时遇到问题,希望有人可以帮助我:我在/wordpress
目录中安装了 wordpress。因此,如果有人访问“www.mysite.com”或“mysite.com”,我想重定向到/wordpress
.
我在服务器上有一些网站,比如/deleted.html
所以我添加了一个 404-Errorpage: ErrorDocument 404 /wordpress/404.php
。如果您访问,则一切都适用于 404 页面,mysite.com/deleted.html
但如果您访问www.mysite.com/deleted.html
. 在这种情况下,首先会出现 301 重定向,然后会加载 404 页面。这对 Google 来说是个问题,因为他们无法检测到该页面已被删除。这是它的样子:
curl -I -L http://www.mysite.com/deleted.html
HTTP/1.1 301 Moved Permanently
Date: Tue, 24 Sep 2013 16:02:18 GMT
Server: Apache/2.2.25 (Unix)
Location: http://mysite.com/deleted.html
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 404 Not Found
Date: Tue, 24 Sep 2013 16:02:18 GMT
Server: Apache/2.2.25 (Unix)
X-Powered-By: PHP/5.2.17
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
X-UA-Compatible: IE=edge,chrome=1
Content-Type: text/html; charset=UTF-8
这是我的 .htaccess
ErrorDocument 404 /wordpress/404.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ wordpress
RewriteCond %{HTTP_HOST} ^(www.)?mysite.net$
RewriteRule ^(/)?$ wordpress
感谢您提供的任何帮助。