2015-11-20 132 views
1

我有一個老域名可以稱之爲舊域名301重定向到新域名與.htaccess的通配符

example.com 

我想要做的所有網頁的301重定向和它的主頁,

newsite.com 

因此,例如

example.com/category/page.html 

應該301重定向到

newsite.com/category/page.html 

而且還

example.com should redirect to newsite.com 

WWW或加www

無論是我嘗試以下

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^example.com [NC,OR] 
RewriteCond %{HTTP_HOST} ^www.example.com [NC] 
RewriteRule ^(.*)$ http://www.newsite.tv/$1 [L,R=301,NC] 

我的文件夾結構

index.html 
.htaccess 

當我進入網站時,無論是否使用通配符,它​​只加載index.html,而.htaccess重定向不起作用。

我也能modrewrite

任何人都可以引導我樹立正確​​的.htaccess這種情況。

謝謝!

+0

您的評論「當我在現場去,無論是通配符與否,只加載的index.html」並不完全清楚。你能否澄清你在瀏覽器中輸入哪個URL,以及index.html文件加載到哪個網站?你是否被重定向到'newsite.com'或者你是否在'example.com'上? – Kay

回答

0

您也可以使用RedirectMatch指令。

試試這個在OLDDOMAIN /的.htaccess:

RedirectMatch ^/(.*)$ http://newsite.com/$1 
相關問題