RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
需要将此第二部分添加到子域代码
RewriteCond %{HTTP_HOST} ^([a-zA-Z]+\.)?somesite.com
RewriteRule ^(.*) index.php?city=%1 [L]
尝试不同的例子,但不能正常工作。
如何组合这两个代码?
答案 0 :(得分:0)
试试这个
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([a-zA-Z]+)\.example\.com$ [NC]
RewriteRule ^.*$ index.php?city=%1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [NC,L]