301 redirect throws an error saying the page being redirected does not exist

时间:2015-07-28 17:00:56

标签: .htaccess redirect

i want to redirect from a page at /roofing/bellevue/index.php to /bellevue-roofing.php I entered the following:

Redirect 301 /roofing/bellevue/index.php http://www.emeraldstate.com/bellevue-roofing.php

into .htaccess in the root directory.

The result of entering www.emeraldstate.com/roofing/bellevue/index.php is:

The requested URL /roofing/bellevue/index.php was not found on this server. I have checked and rechecked various sources on formatting Redirects and everything seems correct. Can anyone provide a little guidance?

1 个答案:

答案 0 :(得分:0)

正确的实现是避免将域名指定为重定向的一部分。虽然这很可能对您的设置没有任何影响,但无论如何我都会提到它。

您最好使用RedirectMatchmod_rewrite(我更喜欢):

RedirectMatch 301 ^/roofing/bellevue/index.php$ /bellevue-roofing.php

或者使用mod_rewrite(确保已启用扩展程序,通常是这样):

RewriteEngine On
RewriteRule ^/roofing/bellevue/index.php$ /bellevue-roofing.php [R=301,L]