Mobile app version of vmapp.org
Login or Join
Murphy175

: Why can't I redirect www to non-www on my addon domain? I have a domain example.com in which I'm doing this to redirect all my traffic from www version to non-www: RewriteEngine On RewriteCond

@Murphy175

Posted in: #AddOnDomain #Apache #Domains #Htaccess #Subdomain

I have a domain example.com in which I'm doing this to redirect all my traffic from www version to non-www:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ %1/ [R=301,L]


Everything fine until now. I can do example.com to example.com, but I also have another domain which I am hosting on the same account as a addon domain. Like there is a folder like example.org in my base www directory of example.com.

Now when I'm doing example.org, I get example.com/example.org with an additional 404.

Hope you get my point. Thanks in advance.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murphy175

1 Comments

Sorted by latest first Latest Oldest Best

 

@Turnbaugh106

This occurs because the .htaccess will be inherited in all child directories. This is a common issue when using add-on domains because each domain shares the same path environment.

This can be resolved by any of the following:


Use more secure hosting with jailed accounts
Use a .htaccess in each add-on domain child directory
Use %{HTTP_HOST} ^www.example.com [NC] rather than %{HTTP_HOST} ^www.(.+)$ [NC]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme