Web Hosting Talk







View Full Version : Two Redirects in .htaccess?


rangy
12-23-2009, 10:56 PM
I have a site and I want to add a 301 redirect for non-www to www. I found the code but when I checked my .htacces I already have this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

How can I now also add this rewrite rule below , too and combine them? Thanks.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
RewriteRule ^.*$ www.%1.%2%{REQUEST_URI} [R=301,L}