Hello,
I am wondering if anyone knows the solution to this.
I am trying to get htaccess redirects working seamlessly from www. to non www. and vice versa when using SEO friendly urls but I am a little stuck and presume it has something to do with the SEO friendly urls rewrite.
When I try forwarding a non www domain to the www like so, I get
http://www.domain.com/index.php?q=services instead of
http://www.domain.com/services
eg
forwarding...
http://domain.com/services
to the www equivalent of...
http://www.domain.com/services
returns this instead...
http://www.domain.com/index.php?q=services
The same happens in reverse. When I try forwarding a www domain to the non www like so, I get
http://domain.com/index.php?q=services instead of
http://domain.com/services:
eg
forwarding...
http://www.domain.com/services
to the non www equivalent of...
http://domain.com/services
returns this instead...
http://domain.com/index.php?q=services
Any ideas on how to make the 2 rules work together?
This is the relevant code in my htaccess file
RewriteEngine on
RewriteBase /
#rewrite URLs to make Search Engine Friendly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
#redirect non www to www
RewriteCond %{HTTP_HOST} !^www\.DOMAIN\.com$
RewriteRule ^(.*)$ http://www.DOMAIN.com/$1 [R=301]
Thanks in advance.
[ed. note: nickf08 last edited this post 13 years, 8 months ago.]