2012-06-18 14 views
1

我有一個Web應用程序,在這裏我把一個子域爲每個客戶如:http://clientNo32.myApp.com 由於一些服務器hazzling我在http://123.456.78:1002/clientNo32/app/index.phpmod_rewrite的:剝去子域,並轉換爲URL參數

這個東西轉到我的新服務器

文件夾「clientNo32」不存在,它只是我想從URL獲取的參數。

我該如何做到這一點?

+0

所以,你要轉換什麼'/ clientNo32 /應用/ index.php'什麼? –

+0

我想將其更改爲/app/index.php?cId=clientNo32 - 應將cId變量附加到每個查詢字符串。 最簡單的方法是使用會話,但我的客戶可以在2或3個工作空間上同時工作。所以我不能使用會話,因爲您不能在多個瀏覽器實例中進行多個會話......我是對的嗎? – Kinesias

回答

2

我想你想要做這樣的事情?

RewriteEngine On 

# Don't know if you need this, exclude www hosts 
RewriteCond %{HTTP_HOST} !^www [NC] 

# Make sure we don't already have a "cId" in the query string 
RewriteCond %{QUERY_STRING} !cId= 

# match the subdomain 
RewriteCond %{HTTP_HOST} ^([^\.]+)\.myapp.com$ [NC] 

# add subdomain to URI as a query string 
RewriteRule ^(.*)$ /app/index.php?cId=%1 [L,QSA] 

這使得它如此,當你要求什麼開始http://clientNo32.myApp.com/,它就會被改寫爲/app/index.php?cId=clientNo32