Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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?

like image 574
phantomCoder Avatar asked Nov 14 '22 02:11

phantomCoder


1 Answers

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]
like image 60
Jevgenij Evll Avatar answered Nov 24 '22 00:11

Jevgenij Evll