[lug] org net redirect or modrewrite to com

Ted Logan ted.logan at gmail.com
Wed Aug 1 09:57:58 MDT 2007


On 8/1/07, dio2002 at indra.com <dio2002 at indra.com> wrote:
> If you want one vhost site to serve all the tld's that have been
> registered for it what's the best method to route the .org and .net to
> .com?

How do you want the sites to show up? If you want the exact same
content to be replicated across multiple domains, you can use a
ServerAlias rule inside your VirtualHost. If you use this rule,
http://www.blah.com/random.html, http://www.blah.org/random.html, and
http://www.blah.net/random.html all point to the exact same file.

<VirtualHost *>
        ServerName      www.blah.com
        ServerAlias     www.blah.org www.blah.net

        # VirtualHost rules continue here
</VirtualHost>

I'd consider using a redirect rule to redirect all of the alternate
domains to one "canonical" domain name. (Among other things, server
alias rules confuse cookies, since the cookie is stored using the host
that the browser connected to. This means that someone visits
blah.com, sets a cookie, and later follows a link to blah.net, the
cookie won't be set.) In this example, requests for
http://blah.com/random.html or http://www.blah.net/random.html will be
redirected (302, but I think you can change that in the Redirect rule)
to http://www.blah.com/random.html.

<VirtualHost *>
        ServerName      blah.com
        ServerAlias     blah.org www.blah.org blah.net www.blah.net

        Redirect / http://www.blah.com
</VirtualHost>
<VirtualHost *>
        ServerName      www.blah.com

        # VirtualHost rules continue here
</VirtualHost>

-- 
Ted Logan
Software Engineer
ted.logan at gmail.com
http://jaeger.festing.org/



More information about the LUG mailing list