Posted By: vanachte ()
Posted On: 03/27/2008 09:27 am
|
Hi There,
I have tried searching but for some reason cant seem to find a post that has this question answered - hopefully I didn't accidentally skip by one.
Basically I am trying to get code for the .htaccess file that will do the following.
301 redirect ALL sub domain requests that have the WWW to that without the WWW.
For instance, if someone tries to access:
http://www.subdomain.topleveldomain.com/* I want it to 301 to
http://subdomain.topleveldomain.com/*
The site this is for has dozens and dozens of sub domains, so if there is code that would work using a wildcard for the sub domain, that would be ideal.
Many thanks in advance
|
|
Posted By: vanachte ()
Posted On: 03/27/2008 11:24 am
|
I actually am looking for this info to help out someone else. Here is a snippet he asked me to add to this post. This is what he has done, thus far, and it does not work yet.
Basically what this is saying is:
1. If the url is not www.demo.com*
2. If the url is not empty
3. If the url MATCHES www.*.demo.com
Then
4. Rewrite www.*.demo.com to be *.demo.com
|
|
Posted By: g1smd (Moderator)
Posted On: 03/27/2008 06:00 pm
|
Dangerous code.
The [R] gives a 302 redirect. You need [R=301,L] here.
The $1 needs to be http://$1 at the very least, too.
Finally, the RewriteRule cannot see the www. part of the URL. It can only see the folder and filepath without a leading / on it.
Correct those problems and post your best attempt.
|
|
Posted By: vanachte ()
Posted On: 04/04/2008 10:54 am
|
Many thanks!! I have sent your reply over to the programmer - will post again when we know if it worked along with the actual code used.
Happy Friday!
|
|
|