NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Web Hosting Discussion
Reload this Page .htaccess - Redirect sub-domains except www

Web Hosting Discussion Hosting topics including DNS, control panels, servers, choosing a host, support.

Advanced Search
3 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 03-14-2010, 04:20 PM THREAD STARTER               #1 (permalink)
Senior Member
 
musicplace.co.nr's Avatar
Join Date: Oct 2007
Location: Sydney, Australia
Posts: 1,022
musicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud of
 



Alzheimer's

.htaccess - Redirect sub-domains except www


Hi,

I know how to redirect all subdomains using a .htaccess file, but how do I exclude www from redirected.

E.g. australia.music-chart.info -> redirects to Australia Music Chart | ITunes Music Chart Archive
japan.music-chart.info -> redirects to www.music-chart.info/japan
etc...

but www.music-chart.info redirects to www.music-chart.info/www and I don't want it too.

The code I currently have in my .htaccess is:

Code:
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.music-chart\.info
RewriteRule ^$ http://www\.music-chart\.info/%2 [R=301]
Thanks,
????: NamePros.com http://www.namepros.com/web-hosting-discussion/644926-htaccess-redirect-sub-domains-except-www.html
Richard
musicplace.co.nr is offline   Reply With Quote
Old 03-14-2010, 07:26 PM THREAD STARTER               #2 (permalink)
Senior Member
 
musicplace.co.nr's Avatar
Join Date: Oct 2007
Location: Sydney, Australia
Posts: 1,022
musicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud ofmusicplace.co.nr has much to be proud of
 



Alzheimer's
Nevermind... this worked:

Code:
RewriteCond %{HTTP_HOST} !^www\.music-chart\.info$
RewriteCond %{HTTP_HOST} ^([^.]+)\.music-chart\.info$
RewriteRule ^$ http://www\.music-chart\.info/%1 [R=301]
If theres a better way to do this, let me know.
musicplace.co.nr is offline   Reply With Quote
Old 03-15-2010, 02:14 PM   #3 (permalink)
NamePros Regular
Join Date: Apr 2008
Posts: 371
XeHSean is an unknown quantity at this point
 




The way you have it now is the best way that I can think of
__________________
XeHost.net - Hosting websites since 1999!
Shared Hosting, Reseller Hosting, VPS Hosting, and Dedicated Servers
Free WHMCS, End-User Support, and WHMReseller for Reseller Hosting Packages!
Follow us on Twitter - new special every Sunday! @XeHost
XeHSean is offline   Reply With Quote
Old 03-16-2010, 01:40 AM   #4 (permalink)
NamePros Regular
Join Date: Nov 2009
Posts: 656
WebIntellects - Rob will become famous soon enoughWebIntellects - Rob will become famous soon enough
 



Originally Posted by XeHSean View Post
The way you have it now is the best way that I can think of
Asking web hosting provider to do that redirect on the side of the server is the best option as for me.
__________________
Use coupon "Rob" and get 10% discount for any payment!
WebIntellects - Fully Managed Dedicated and since 1999.
WebhostGIANT - Low cost hosting from $2.79!
WebIntellects - Rob is offline   Reply With Quote
Reply

Tags
.htaccess


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 09:34 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger