301将任何页面重定向到一个特定页面

时间:2011-06-15 23:39:10

标签: .htaccess

有没有办法只使用htaccess 301重定向将域中的任何页面重定向到另一个域上的特定页面。

例如。我domain.com/index.htmldomain.com/contact.html都重定向到newsite.com/index.html

但我想要这样做而不必专门列出每个页面。

我的301重定向可以像

一样
301 * http://newsite.com/index.html

或如何设置。不幸的是我无法访问mod重写,所以我不能使用mod重写来使它工作。

2 个答案:

答案 0 :(得分:2)

使用wordpress并尝试从页面中删除所有.asp扩展名时出现了与此类似的问题,这已粘贴在我的.htaccess文件的顶部

## 301 Redirects
RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^(.*)\.asp$ $1? [R=301,NE,NC,L]

答案 1 :(得分:0)

是的,这是可能的 - 而不是mod_rewrite,你需要使用mod_alias(它有更多的机会被启用)。

这个会将{strong>所有内容重定向到index.html上的newsite.com/

RedirectMatch 301 ^/(.*)$ http://newsite.com/index.html

此广告会将所有内容重定向到同一路径,但会在另一个域中重定向:(例如oldsite.com/meow.php => newsite.com/meow.php

RedirectMatch 301 ^/(.*)$ http://newsite.com/$1