Forum Moderators: phranque

Message Too Old, No Replies

Special redirection needs

Special redirection needs

         

mannetje21

4:01 pm on Jan 6, 2009 (gmt 0)

10+ Year Member



Hi there,

I am having some problems configuring my server to redirect subdomains correctly.

The following situation exists:

We are running a website that has regional website, we use the placename of the region as a subdomain for example and use one central site where visitors can select their region of choice, so our site has the following sites and subsites:

domainname.com (central site)
aalten.domainname.com (regional site)
gendringen.domainname.com (regional site)
breedenbroek.domainname.com (regional site)
admin.domainname.com (management panel)

Users also might enter www.aalten.domainname.com in their address bar, but i would like the user to be redirected to aalten.domainname.com this should happen for all regional domainnames and the admin site may be included in that.

In essence my wish is to always make Apache drop the www. portion used in the address bar and permanently redirect the user to the corresponding hostname without www.

Is this possible by one Directive which works for any subdomain?

With kind regards,
Erwin

jdMorgan

5:14 pm on Jan 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From this thread [webmasterworld.com], posted two days ago:

# Externally redirect to canonical non-www hostnames
RewriteCond %{HTTP_HOST} ^www\.(([^.]+\.)*)example\.com
RewriteRule (.*) http://%1example.com/$1 [R=301,L]

See the resources available in our Apache Forum Charter and in our Apache Forum Library before attempting to use this code. The code will need slight modification if it is to be run at the server config level.

Jim