htaccess的:
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
答案 0 :(得分: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]