We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,721 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

htaccess-conditional subdomain removal?

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

2
Contributors
1
Reply
4 Days
Discussion Span
1 Year Ago
Last Updated
2
Views
Midgard
Newbie Poster
9 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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

manojsamtani
Light Poster
Banned
37 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0554 seconds using 2.7MB