0

Hi-

I'm trying to figure out how to remove a subdomain from a URL in htaccess, but only if there is a path after the domain.

Examples:

http://www.subdomain.mysite.com/ - OK
http://subdomain.mysite.com/ - OK

http://www.subdomain.mysite.com/folder1/index.php - becomes: http://www.mysite.com/folder1/index.php

http://subdomain.mysite.com/folder1/index.php - becomes: http://mysite.com/folder1/index.php

Any clues?

Many thnx in advance,

-Midgard

Edited by Midgard: n/a

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by manojsamtani
0

Hi-

I'm trying to figure out how to remove a subdomain from a URL in htaccess, but only if there is a path after the domain.

Examples:

http://www.subdomain.mysite.com/ - OK
http://subdomain.mysite.com/ - OK

http://www.subdomain.mysite.com/folder1/index.php - becomes: http://www.mysite.com/folder1/index.php

http://subdomain.mysite.com/folder1/index.php - becomes: http://mysite.com/folder1/index.php

Any clues?

Many thnx in advance,

-Midgard

Use below given rewrite rules for this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.mysite.com$
RewriteRule ^/folder1/index.php$ http://mysite.com/$1 [R,L]


RewriteCond %{HTTP_HOST} ^www.subdomain.mysite.com$
RewriteRule ^/folder1/index.php$ http://www.mysite.com/$1 [R,L]


Thanks,
Manoj
links deleted by mod

Edited by crunchie: blog links deleted

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.