943,520 Members | Top Members by Rank

Jun 21st, 2009
0

Force WWW except for Subdomains Issue

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wolfy834 is offline Offline
4 posts
since Jul 2004
Jun 23rd, 2009
0

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?
Moderator
Staff Writer
Reputation Points: 154
Solved Threads: 18
Linux Reject
blud is offline Offline
570 posts
since Apr 2004
Jun 25th, 2009
0

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wolfy834 is offline Offline
4 posts
since Jul 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Linux Servers and Apache Forum Timeline: local host problem
Next Thread in Linux Servers and Apache Forum Timeline: If You Like Mini Laptops, Say Yes sir to Acer





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC