2012-02-20 121 views
0

我困在遵循htaccess的情況。將變量頁面重定向到變量子域通配符

我想重定向頁面,子域。

現在地址例子;

http://domain.tld/user/foo

我需要這個重定向到;

http://foo.domain.tld

子站點是通過通配符genereated。

我試過了,沒有成功;

RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC] 
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$ 
RewriteRule (.*) s/index.php?user=%1 [NC,QSA] 
RewriteRule ^user/(.*) (.*) [R=301,L] 

問候,

尼克

+0

您是否設置爲每個用戶一個子域? – ThinkingMonkey 2012-02-20 20:17:09

+0

它通過通配符('* .domain.tld')的動態,所以只有一個子域抓住所有可能。 – directory 2012-02-20 22:01:56

回答

0
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC] 
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$ 
RewriteRule (.*) s/index.php?user=%1 [NC,QSA] 

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.tld [NC] 
RewriteRule ^user/([a-zA-Z0-9-.]+) http://$1.domain.tld/ [R=301,L] 
+0

嗯,沒有做詭計,但也沒有內部服務器錯誤。 – directory 2012-02-21 19:52:34

+0

嘗試編輯我上面提出的 – Gerben 2012-02-21 20:58:08

相關問題