Brandon Stout wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lonnie Olson wrote:
On Tue, Apr 7, 2009 at 7:37 AM, Justin Hileman wrote:
<IfModule mod_rewrite.c>
# Canonical domain name rewrite
RewriteCond %{HTTP_HOST} !^justinhileman\.info$ [NC]
RewriteRule (.*) http://justinhileman.info/$1 [L,R=301]
</IfModule>
Justin's method accomplishes your goals, keeps you down to a single
Vhost per site. BTW as Justin mentioned mod_rewrite can give a
"permanent" redirect too.
--lonnie
This is what I was talking about, but I used the wrong name. I should
have looked up the name before I sent the post. This accomplishes the
same thing, but it seems it would require more processing. It also
doesn't tell the world that the URL was incorrect - a permanent
redirect. I'm thinking this is the better method for SSL domain
forwarding since you have to put the certificate in there. I'm not
convinced this is the best method for regular domain redirects. I'm
open minded on this, and still curious if there are more opinions on it.
Maybe this is the better method, and maybe 'better' is whatever you
like it to be. Does this take more processing? Would it be
significantly more for a machine that hosts hundreds of domains? Is it
better form to send the Internet a message saying "this domain is a
permanent redirect to that one"?
That's exactly what my mod_rewrite rule does...
Mod rewrite is really flexible. The flags at the end can tell it to do
any kind of rewrite you want. In my case, I use the [R=301] to do a
permanent (301) external redirect.
It just has the added benefit of allowing redirects to any address in
the domain rather than the base url. Here, try it:
http://www.justinhileman.info/archive
In fact, here's a double redirect:
http://www.justinhileman.info/archive/2008/04
It resolves the canonical domain (anti-www) redirect first, then
redirects from my old `archive/YYYY/MM` urls to my new single-page
archive urls. The headers in both cases are 301--permanent redirect.
Isn't mod_rewrite fun? :)
The processing time for mod_rewrite is approximately the same as
processing a Perl regex. AKA negligible when compared to processing
*any* PHP at all.
(Side note: Don't judge performance of mod_rewrite based on my server
speed. I have a leaky Python script that eats all available resources
and has to be kill -9'd by my monitoring daemon about once an hour...
Some day I'll have time to fix that beast.)
--
justin
http://justinhileman.com
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net