phantomCoder
phantomCoder

Reputation: 1587

.htaccess redirect main domain and addon domain issue

I have a domain name maindomain.com

In the main domain I have a blog. The main domain is not active now. So all requests to site root index.php is redirected to maindomain.com/blog using htaccess.

I have this in htaccess for redirection

Redirect /index.php http://www.maindomain.com/blog/
Options All -Indexes

Everything works fine.

Now I added an Addon domain. The addon domain root folder is maindomain.com/addondomain.com

addondomain.com folder has an index.php. When I am accessing addondomain.com in the browser its getting redirected to http://www.maindomain.com/blog/ How to prevent this?

Upvotes: 5

Views: 2491

Answers (1)

Jevgenij Evll
Jevgenij Evll

Reputation: 1889

I assume that your additional domain has a different host: addondomain.com ?

In this case, simply add this condition to your .htaccess:

RewriteCond %{HTTP_HOST} maindomain.com$ [NC]

So the full redirection rule would look like this:

RewriteCond %{HTTP_HOST} maindomain.com$ [NC]
RewriteRule /index.php$ http://www.maindomain.com/blog/ [R]

Upvotes: 1

Related Questions