如何使用htaccess将整个网站及其所有页面/URL重定向到新站点?
How do I redirect an entire website and all of its pages/urls to a new site using htaccess?
当我尝试以下操作时,它仅将旧站点的主页重定向到新站点.
When I tried the below, it only redirected the home page of the old site to the new site.
重定向301/www.newsite
当我尝试以下操作时,首页被重定向,但是旧站点上的其他页面( www.oldsite/register )获得了404.
When I tried the below, the home page was redirected, but the other pages (www.oldsite/register) on the old site got 404.
RewriteEngine on RewriteCond %{HTTP_HOST} ^oldsite\$ [OR] RewriteCond %{HTTP_HOST} ^www\.oldsite\$ RewriteRule ^/?$ "http\:\/\/www\.newsite\\" [R=301,L]例如:
www.oldsite-> www.newsite
www.oldsite --> www.newsite
www.oldsite/register-> www.newsite
www.oldsite/register --> www.newsite
www.oldsite/images/cats-> www.newsite
www.oldsite/images/cats --> www.newsite
推荐答案据我了解,您需要将旧域中的所有内容重定向到新域中的索引页面,因此以下代码应该为您工作:
as i understand you need to redirect every thing in old domain to just index page in new domain , so The following code should work for you:
RewriteEngine On RewriteRule ^(.*)$ www.NEWDOMAIN [R=301,L]更多推荐
使用htaccess重定向整个站点
发布评论