1

as you may know zend framework uses .htaccess for redirection purposes

so when I tried to follow this advice: http://techpp.com/2010/06/28/how-to-redirect-www-urls-to-non-www-urls-and-non-www-to-www/

in conjuction with the necessary .htaccess code for zend framework, the redirection works fine, but zend stopped working properly...

does anyone know how to achieve this task without messing up zend framework

current rules:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
  • Can you post your current rewrite rules? – slillibri Jan 24 '11 at 3:34
2

I have something similar in a project of mine. The following redirects a non-www requests to a www request:

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]

A similar thing should work for redirection from www to non-www:

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]
  • Thanks! I'd been searching for this all morning. Works perfectly. – user900456 Oct 20 '11 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.