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

Hello

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

example
www.mysite.com
blog.mysite.com
lll.mysite.com
and even a
*.mysite.com (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 mysite.net, mysite.org and mysite.co.uk domain names.

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

Example
www.mysite.org -> www.mysite.com
blog.mysite.co.uk/this/is/a/page -> blog.mysite.com/this/is/a/page
...

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 ?

Thanks
presedo
 
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

my.sub.domain.mysite.org ->
my.sub.domain.mysite.com

this.is.mysite.net/file.php5?var=one&var2=two ->
this.is.mysite.com/file.php5?var=one&var2=two

and
bla.mysite2.net -> 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...)
presedo
 
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]
richardk
 
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 7 guests

cron