Forum Moderators: phranque

Message Too Old, No Replies

.htaccess help - subdomains and redirect

htaccess, subdomain, redirect

         

thecanuck

3:48 am on Apr 10, 2010 (gmt 0)

10+ Year Member



Hi all,

My first time to WebmasterWorld.com, and I've tried to find my answer within the forum, and wasn't able too... hopefully someone can help me?

I'm trying to do the following...

www.domain.com --> domain.com
wildcard.domain.com --> domain.com

www.domain.com/test/ --> domain.com/test/
wildcard.domain.com/test/ --> domain.com/test/

www.domain.net --> domain.com
wildcard.domain.net --> domain.com

Please help! Thanks.

g1smd

7:03 am on Apr 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The standard rule, posted several times per week, will do the job.

# Canonical Redirect non-www to www
# Also caters for non-blank host, unwanted port numbers, etc.
RewriteCond %{HTTP_HOST}  !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


It also takes care of example.com:80 and www.example.net:80 and so on.

thecanuck

3:27 pm on Apr 10, 2010 (gmt 0)

10+ Year Member



Thanks g1smd, that's a far I've gotten, unfortunately, this is not the correct solution.

I want the following to happen:

any sub-domain to redirect to the domain, for example:

w.domain.com --> domain.com
test.domain.com --> domain.com
etc...

Any ideas?

g1smd

5:36 pm on Apr 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As long as that code is in the place those widcard sub-domains resolve to, that code will work.

If the DNS is not set right, it can never work.