The MU forums have moved to

[Contrib] How-TO Use rewrite to handle multiple Domain Names (2 posts)

  1. DarkPepe
    Posted 17 years ago #

    [NOTE: This was designed for subdomain instalations]

    Hi, I'm currently using 2 domains on my MU instalation:


    I started using first the .CL domain and after a couple of months, I switch the complete instalation to the .NET domain.

    The Problem was, I need the old .CL URLS to resolve on the .NET adress for traffic, RSS and other related stuf.

    I found a preatty clever way to manage this situation using apache2 mod_rewrite.

    How To:

    The situation is the Following

    Main Domian: MAIN.NET
    Secondary Domain (It Will redirect to Main): Secondary.COM

    Virtual Host file for Secondary.COM

    <VirtualHost Secondary.COM>
    DocumentRoot /home/foo/bar
    DirectoryIndex index.php index.htm
    ServerName Secondary.COM
    ServerAlias http://www.Secondary.COM
    RedirectMatch (.*)$ http://MAIN.NET$1
    RedirectMatch (.*)/$ http://MAIN.NET$1
    RedirectMatch (.*).php$ http://MAIN.NET$1.php
    <Directory "/home/foo/bar">
    Options +FollowSymLinks
    AllowOverride All
    allow from all
    RewriteEngine On
    RewriteRule .* - [F]
    RewriteRule !^(..*|/)$ %{REQUEST_URI}/ [R=301,L]

    This will redirect all the requests to to Main.NET, for example:

    Will change to:


    You can test it on my domains:

    Main: http://losblogs.NET
    Secondary (redirecting): http://losblogs.CL

    It will redirect to:

    other example:

    Will redirect to:


    I hope this can help those ppl who has a 2 or more domains for their MU instalation.


    PD: You can check the full Virtualhost file on txt format here:

  2. andorko
    Posted 17 years ago #

    This might be simpler

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST}   !^ [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteRule ^/(.*)$1 [R=301,L]

About this Topic

  • Started 17 years ago by DarkPepe
  • Latest reply from andorko