htaccess将所有页面重定向到单页

问题描述:

我想使用htaccess文件将我所有的旧域名请求重定向到我的新域。以下是我正在使用的,但如果该网页不在新网站上,则无效。例如,在旧站点上的google index about.htm,但是在新站点上它不存在。在所有情况下,我都希望它能够根深蒂固。我知道这不是理想的seo,但我不想要任何404。任何建议?

I want to redirect all of my old domain request to my new domain using htaccess file. Below is what I am using but it does not work if the page is not on the new site. For example google index about.htm on the old site but on the new site it does not exist. I would like it to just go to the root in all cases. I know this is not ideal for seo but I don't want any 404s. Any suggestions?

Redirect 301 / http://www.thenewdomain.com/


您是否想访问old.com/about.htm以访问new.com/ about.htm中?如果是这样,可以使用.htaccess中的mod_rewrite规则:

Are you trying to get visitors to old.com/about.htm to go to new.com/about.htm? If so, you can do this with a mod_rewrite rule in .htaccess:


RewriteEngine on

RewriteRule ^(。*)$ http://www.thenewdomain.com/$1 [R = permanent,L] code>

RewriteRule ^(.*)$ http://www.thenewdomain.com/$1 [R=permanent,L]