sub.domain.com => sub.domain.net

Using a single web hosting account to host multiple sites

sub.domain.com => sub.domain.net

Postby DarkPepe » Fri Dec 15, 2006 1:13 am

Using: Apache2 + php5
OS: Debian ETCH

Hi, Im trying to mix up a little mod_alias and rewrite to make this work:

I need to handle redirections from my old domain, with all his subdomains and files, to a new domain, examples:

http://test.losblogs.cl has to redirect to http://test.losblogs.NET


Then, http://test.losblogs.cl/page/ to http://test.losblogs.NET/page/

http://test.losblogs.cl/script.php to http://test.losblogs.NET/script.php

I have a wildcard DNS because I'm a bloghost, so there are tons of subdomains that have to be redirected from .CL to .NET

My solution so far (I'm a Noob) is doing some alias redirection:

For base domain vhost:

Code: Select all
RedirectMatch (.*)\$ http://losblogs.net$1
RedirectMatch (.*)\/$ http://losblogs.net$1
RedirectMatch (.*)\.php$ http://losblogs.net$1.php


And rewrite for trailing slash:

Code: Select all
RewriteRule !^(\..*|/)$ %{REQUEST_URI}/ [R=301,L]



So here is it working:

http://losblogs.cl Will redirect to http://losblogs.net

http://losblogs.cl/soporte will redirect to http://losblogs.net/soporte

http://losblogs.cl/soporte/ will redirect to http://losblogs.net/soporte/

http://losblogs.cl/index.php will redirect to http://losblogs.net/index.php

Now, my problem is to create the same effect on subdomain.losblogs.CL to redirect to subdomain.losblogs.NET, I dont know what to add on the vhost of the wildcard dns.


Thank you so much.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm

Postby richardk » Fri Dec 15, 2006 10:36 am

You need Wildcard DNS. Look in your domain control panel, or ask your domain registrar. All the domains and sub domains you want redirected should go to the same document root. If you can't do it post your <VirtualHost>s.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^((.*\.)?losblogs\.)cl$ [NC]
RewriteRule ^(.*)$ http://%1net/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby DarkPepe » Fri Dec 15, 2006 11:02 am

richardk wrote:You need Wildcard DNS. Look in your domain control panel, or ask your domain registrar. All the domains and sub domains you want redirected should go to the same document root. If you can't do it post your <VirtualHost>s.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^((.*\.)?losblogs\.)cl$ [NC]
RewriteRule ^(.*)$ http://%1net/$1 [R=301,L]



I use everydns.net to master my domains, in there I have a wilcard A record:

*.losblogs.cl A 200.72.204.154

And on apache I've just added the rule you write and it works!!! thank you so much!!

You made my day.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 17 guests

cron