在zend框架中如何通过htaccess将www.example.comredirect到example.com

正如你可能知道zend框架使用.htaccessredirect的目的

所以当我试图按照这个build议: http : //techpp.com/2010/06/28/how-to-redirect-www-urls-to-non-www-urls-and-non-www-to-www /

结合必要的.htaccess代码为zend框架,redirect工作正常,但zend停止正常工作…

有没有人知道如何实现这个任务,而不会搞乱zend框架

目前的规则:

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

我在一个项目中有类似的东西。 以下内容将非www请求redirect到www请求:

 RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] 

类似的事情应该从www到非www的redirect工作:

 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule (.*) http://example.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]