2012-07-04 89 views
0

的.htaccess:的.htaccess mod_rewrite的子域

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{HTTP_HOST} ^site\.com$ [NC] 
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301] 
RewriteRule ^new/?$ index.php?section=new 

這個偉大的工程,所有的,但我最近實施的一個子m.site.com讀取掀起了/mobile目錄。當訪問m.site.com/new時,它不會顯示任何內容,除了返回服務器錯誤。我能做些什麼來糾正這個問題?

基本上,我想http://m.site.com/new

爲了達到相同的效果作爲http://www.site.com/new

回答

1

您可以指向m.site.com/然後:

RewriteEngine On 
RewriteBase/


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{HTTP_HOST} ^site\.com$ [NC] 
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301] 

# here i added [L] flag to stop rules matching 
RewriteRule ^new/?$ index.php?section=new [L] 

# everything that is not in new/* will still get redirected to the "old" mobile site 
RewriteCond %{HTTP_HOST} ^m\.site\.com$ 
RewriteRule (.*) /mobile/$1 [L,QSA]