2015-02-10 78 views
2

我試圖找出如何我的.htaccess看起來應該做到以下幾點:使用.htaccess將文件路徑的一部分重定向到新域?

獲取,看起來像

{協議} thedomain.co.uk/home/任何網址{ URI的其餘} URI的

OR

{協議} www.thedomain.co.uk/home/ {其餘}

重定向到

{協議} {subdomain.thedomain.co.uk/home/ URI的其餘}

應該很簡單但我有一個正則表達式技巧5歲。任何幫助讚賞。

回答

2

將此項添加到您網站根目錄的.htaccess文件中。

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(www\.)?thedomain\.co\.uk [NC] 
RewriteCond %{HTTPS}s ^on(s)|off 
RewriteRule ^(home/.*)$ http%1://subdomain.thedomain.co.uk/$1 [R=301,L] 
+0

只是一個簡單的問題,我怎麼讓這個如果URL是thedomain.co.uk/home它,而不是thedomain.co.uk/home/它被重定向呢? – styke 2015-02-10 16:37:58

+1

改爲使用'RewriteRule ^(home(/.*)?)$''。 – 2015-02-10 19:48:04

相關問題