好的,目的是爲我們的成員動態創建無限數量的子域。 因此,對www.example.com/sub_index.php?user=demo的請求將轉換爲demo.example.com網址,而www.example.com由index.php提供。子域中的子頁面
我已經啓用名稱服務器和Web服務器來接受通配符請求(實際上我聯繫我的託管服務器來做到這一點)。
在htaccess的一部分,我有以下幾點:
####rewrite example.com into www.example.com
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.htm([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ http://www.example.com/$1 [R=301,L]
####subdomains
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]+)\.example.com
RewriteRule ^(.*)$ sub_index.php?user=%1
因此,請求demo.example.com/和demo.example.com/index.php由www.example服務。 ?COM/sub_index.php用戶=演示
我的問題是,我不能找到一種方法,有子頁面的子域 例如工作:demo.example.com/somepage.php應該由www.example送達。 com/sub_page.php?user = demo 而demo.example.com/otherpage.php?id=5應該由www.example.com/sub_page2.php?user=demo & id = 5。
謝謝你的任何建議/提示
重寫規則^ /(A-ZA-Z0-9 _] + \。PHP)/ sub_ $ 1?USER =%1 qsappend] 這部作品sub_index.php 但給我sub_other_page.php 404錯誤 這兩個頁面都上傳到根文件夾中 – andrew 2011-04-11 13:23:48