Non-www to www Redirects
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, url, url-rewriting, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :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 my main domain without affecting my addon domains.
My redirect code is:
RewriteCond %HTTP_HOST ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.HTTP_HOST/$1 [R=301,L]
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 ^(.*)$ http://www.example.com/$1 [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.
Comments
Post a Comment