Ogugua Belonwu
Ogugua Belonwu

Reputation: 2141

Addon domains redirect to main domain

I have a hosting service with two addon domains.

All was working well till few weeks ago.

If I enter www.addon1.com, it redirects to www.mainwebsite.com. Same happens for www.addon2.com.

But if I enter www.addon1.com/index.php, it loads properly.

I really do not know what the problem is.

Is there anything I can do ( htaccess or something else ) to ensure that www.addon1.com does not redirect to www.mainwebsite.com

EDIT

Content of www.addon1.com .htaccess

Options -Indexes

Content of www.mainwebsite.com .htaccess

Options -Indexes
Redirect 301 /index.html http://www.mainwebsite.com/index.php
Redirect 301 /portfolio.html http://www.mainwebsite.com/portfolio/index.php
Redirect 301 /services.html http://www.mainwebsite.com/services/index.php

Upvotes: 4

Views: 894

Answers (2)

Giannis Grivas
Giannis Grivas

Reputation: 3412

You have to create a 'bypass rule' at the top to skip the subsequent rules if the request is for the addon (in our case the www.addon1.com).

Add to www.mainwebsite.com 's .htaccess file at the top the following:

    RewriteCond %{HTTP_HOST} ^(www\.)?addon1\.com
    RewriteRule .* - [L]
...

*info for [L] rule here.

  • EXPLANATION

This tells mod_rewrite to quit processing right here if the requested domain is addon1.com or www.addon1.com.

To help you more i tried the senario at this excellent online rule test tool: http://htaccess.madewithlove.be/ and i give you the results.

1st Type: www.addon1.com

Result: Stop processing and other rules below could not met! enter image description here

2nd Type: www.whatever.com

Result: Continue processing and could met other rules! enter image description here

Finally, you can add whatever rule you want bellow this piece of code and it will work! Be carefull,we made changes only to the domain .htaccess file

Hope it helps!

Upvotes: 3

Gene Vincent
Gene Vincent

Reputation: 5469

Your .htaccess for the addon site is missing the 301 redirect:

RedirectMatch 301 /(.*)   http://www.mainsite.de/index.php

You may want to use multiple statements with different patters if you don't want to redirect all requests to the same destination on the main site.

Upvotes: 1

Related Questions