Re: cleanest/fastest way of redirecting aliases to canonical server names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/29/11 2:38 AM, Christoph Anton Mitterer wrote:
Hi.

I'm having a vhost, which is reachable via one canonical name, e.g.
example.org, and also via several aliases, e.g. www.example.org,
example.com, etc.

I want that whenever requests are made via one of the aliases, that
those are redirected to the canonical name.


IMHO there are about the following two ways:
1)
- one vhost, which has the canonical name as ServerName, and the aliases
as ServerAliases
- and also has some RewriteCond+RewriteRules, making a redirect to the
canonical address if HTTP_HOST is one of the aliases.

This is generally the right way only if you have a hosted account, i.e. you only have access to one vhost period.
If you have control over httpd.conf, avoid rewriting as much as possible.

2)
- two vhosts, the first having only the canonical name as ServerName (no
ServerAlias)

- the second, having the aliases as ServerName/ServerAliases
- and also doing a Redirect / http://example.org

That would be my choice.

Can (2) be handled with more performance by Apache than (1) (as it
doesn't have to evaluate the RewriteConds and the regexps every time?

That's quite irrelevant, as the redirect requires an entire network round-trip, not to mention any client-side processing.

Rewrite performance is insignificant compared to the overhead of a network round-trip.

However, the Redirect forces the network round-trip regardless, so it's a moot point.

At least (1) seems to be cleaner readable to me (from a config file
point of view)


No, it's not cleaner at all. Using Rewrites funges your output and makes troubleshooting harder.


--
J.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux