: Non-www to www Redirects I'm trying to redirect my main domain non-www to www but I have this error; my add on domain redirects like this: http://www.example.org/example.org/ How can I redirect
I'm trying to redirect my main domain non-www to www but I have this error; my add on domain redirects like this:
www.example.org/example.org/
How can I redirect my main domain without affecting my addon domains.
My redirect code is:
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ www.{HTTP_HOST}/ [R=301,L]
More posts by @Odierno851
2 Comments
Sorted by latest first Latest Oldest Best
This works much better since it does a redirect on any URL without www to the www version.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ www.example.com/ [R=301,L]
Assuming your addon domain points to a subdirectory off the main domain's document root, then a simple workaround is to create a .htaccess file for the addon domain and simply enable the rewrite engine:
RewriteEngine On
This will prevent the parent directory's mod_rewrite directives being inherited.
However, since you already appear to be checking the HTTP_HOST in your main domain's .htaccess file then this should already be working OK, so I suspect there is something else going on.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.