changing the domain extension to .com only

Using a single web hosting account to host multiple sites

changing the domain extension to .com only

Postby presedo » Tue Nov 27, 2007 8:16 am


I have several virtualhosts configured on my serveur, tha let me use different sub-domains for different purposes.

and even a
* (that redirects all the unknowned subdomains to a single script - In fact, it redirects *.* that comes on that server - this is the last rule declared on my conf file.)

Let say that I owned, and domain names.

What I what to do is whatever domain name is used by the visitor, the server automatically changes it to .com.

Example -> ->

Do I have to create a RewriteRule for each vistualhost ? Is there a possibility to write that rule in the httpd.conf, outside the virtualhost declaration ?

Posts: 19
Joined: Fri Oct 06, 2006 6:10 am

Postby presedo » Tue Nov 27, 2007 8:31 am

Just a little precision

in fact, what I want, is to redirect any access to a "mysite" domain keeping the same URI, but only changing the extension of the subdomain -> ->

and -> does not change because it's not a "mysite" domain

And all those changes must be done before the request is delivered to the script (hope you know what I mean...)
Posts: 19
Joined: Fri Oct 06, 2006 6:10 am

Postby richardk » Tue Nov 27, 2007 8:36 am

Your <VirtualHost>s should only match the hosts you tell it to (with ServerName and ServerAlias) with the exception of the first one which is the default. So, if you don't match .net, etc. you can use the first <VirtualHost> to do one redirect
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(.+)\.com$
# Two part extensions must be defined.
RewriteCond %{HTTP_HOST} ^(.+\.)[^\.]+\.(uk|au)$ [NC,OR]
# All one part tlds get caught here.
RewriteCond %{HTTP_HOST} ^(.+\.)[^\.]+$
RewriteRule ^(/.+)$ http://%1com$1 [R=301,L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 8 guests