在Zend Frame htaccess中重写子域的RewriteCond

时间:2014-02-19 18:15:31

标签: .htaccess zend-framework mod-rewrite

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
  • 来自Zend

需要将此第二部分添加到子域代码

RewriteCond %{HTTP_HOST} ^([a-zA-Z]+\.)?somesite.com
RewriteRule ^(.*) index.php?city=%1 [L]

尝试不同的例子,但不能正常工作。

如何组合这两个代码?

1 个答案:

答案 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]