2015-04-22 92 views
1

我发现一个网站链接到我的网站与www.example.com/home.html不存在。我试图建立一个重定向:301重定向到主页返回404

Redirect 301 /home.html //www.example.com 

但它重定向到www.example.com/www.mysite.com

我可以使用Redirect,或做我必须做一个重写?

回答

0

请使用重写规则:

第一:

Options +FollowSymLinks 
RewriteEngine On 

然后

RewriteRule ^home.html$ http://www.example.com/ [r=301,nc,L] 
+0

这是否需要是其间开始和结束标记,如:。我在本地测试上述内容,但似乎无法使其正常工作。 – brandozz

+0

@brandozz不需要其他行或过滤器来将'http:// example.com/home.html'重定向到'http:// www.example.com /'。它必须在网络中工作。确保没有其他规则与此规则相矛盾。 – Ormoz

0

Redirect 301 /home.html //www.example.com

在这种情况下, ,目标URL(以斜杠开始)被认为是相对于当前方案/主机的根。如果您有适当的设置DirectoryIndex,您可以重定向到/

例如:

Redirect 301 /home.html/