Wednesday, April 11, 2012

Redirect www to non-www

Quick question - I know this should be very easy to figure out myself, but I keep finding conflicting information when I try to find the solution, and I'm a stickler for doing/learning things the right way.

I want to redirect all www traffic to non-www.

I am using a fresh copy of Cake 2.1.1 - no changes have been made to any of the .htaccess files.

/site/.htaccess
==========================
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

/site/app/.htaccess
==========================
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

Which .htaccess file should the rewrite conditions/rules be placed in? What are the proper rewrite conditions/rules to use?

Thanks in advance.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: