0
我接近實現我的目標,但我無法拿出解決我的問題的正確方案。通配符子域的透明重寫/穿透
我寫了下面的規則,我的通配符子域:
#remove www.
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain\.com/$1 [R=301,L]
#rewrite subdomains to /club/<clubname as defined by subdomain>/<whatever was here before>
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/club/%1/$0 [NC,L]
這是拼命接近我要求,即如果我去http://alpha.domain.com/some/string/here的URL改寫爲http://domain.com/club/alpha/some/string/here
然而我想在瀏覽器中的網址仍然看起來像原來的網址
非常感謝在adva NCE
編輯:我曾嘗試只是增加PT的最終規則,但不工作,我得到一個400錯誤
EDIT2:任何有興趣,我放棄了這一行的查詢和而是使用PHP來讀取子域中的文本。
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteCond $0 !^club/
RewriteRule ^(.*)$ club/%1/$0 [NC,L]
否則你:
謝謝,但我得到第一個錯誤500和第二個404錯誤 – amcc 2011-02-10 17:30:34