而不是404错误,使用htaccess重定向到其他网站

时间:2013-03-13 11:11:44

标签: .htaccess redirect http-status-code-301

我们已经将网站移动到另一个域并将htacess设置为如下,但如何设置规则“如果页面dosnt存在 - (即404错误)重定向到新网站主页。”如果有人跟踪我们旧网站上的破坏网址,可以用作退款。

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.oldsite\.co\.uk)(:80)? [NC]
RewriteRule ^(.*) http://oldsite.co.uk/$1 [R=301,L]

Redirect permanent http://oldsite.co.uk http://newsite.co.uk
Redirect permanent http://oldsite.co.uk/index.html http://newsite.co.uk

Redirect permanent http://oldsite.co.uk/contact-us.html http://newsite.co.uk/contact-us.html
Redirect permanent http://oldsite.co.uk/bespoke-furniture.html http://http://newsite.co.uk/bespoke-furniture.html
Redirect permanent http://oldsite.co.uk/about-us.html http://newsite.co.uk/about-us.html   
Redirect permanent http://oldsite.co.uk/how.html http://newsite.co.uk/about-us.html


order deny,allow

1 个答案:

答案 0 :(得分:1)

你可以简单地使用它。

ErrorDocument 404 http://newsite.co.uk