DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Linux Servers and Apache (http://www.daniweb.com/forums/forum33.html)
-   -   Force WWW except for Subdomains Issue (http://www.daniweb.com/forums/thread198787.html)

Wolfy834 Jun 21st, 2009 2:38 am
Force WWW except for Subdomains Issue
 
I've been looking over the same .htaccess codes that will not work for a subdomain. It seems not many people really know how to do a correct .htaccess (including me I suppose). I've tried:

RewriteCond %{HTTP_HOST} !^site\.net$ [NC]
RewriteRule ^(.*)$ http://site.net/$1 [R=301,L]

And it requires the WWW on the subdomain, such as bob.site.net, which I do not want. Does anyone have a solution to my problem?

blud Jun 23rd, 2009 10:41 am
Re: Force WWW except for Subdomains Issue
 
So, basically starting off reading your rule, it says:
If someone accesses this site that is *NOT* from http://site.net
Then redirect them to http://site.net/string

Maybe removing the 'NOT' is what your looking for:
RewriteCond %{HTTP_HOST} ^site\.net$ [NC]
RewriteRule ^(.*)$ http://www.site.net/$1 [R=301,L]

Which would state, if someone is accessing your site from site.net redirect to www.site.net/string

This rule would activate for anyone hitting http://site.net but not http://bob.site.net

Is this the goal?

Wolfy834 Jun 25th, 2009 10:24 am
Re: Force WWW except for Subdomains Issue
 
Yes, that worked. Thanks mate! Its so difficult finding any good information about htaccess. It seems no one really knows it well enough.


All times are GMT -4. The time now is 4:09 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC