Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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]
share|improve this question
    
Can you post your current rewrite rules? –  slillibri Jan 24 '11 at 3:34

1 Answer 1

up vote 2 down vote accepted

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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