[UPHPU] httpd.conf RedirectPermanent

Brady Mitchell mydarb at gmail.com
Wed Apr 8 23:55:07 MDT 2009


On Apr 8, 2009, at 1020PM, Brandon Stout wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Matthew Frederico wrote:
>
>> On Mon, Apr 6, 2009 at 11:29 PM, Brandon Stout wrote:
>>
>>> Are my premises for using it all accurate?
>>
>> Of course they are.  If it gets the job done and you have the  
>> desired results.
>>
>> If socat and a bash script are all you need for your webserver, thats
>> great too.  If its design accomplishes your purpose - that's the way
>> to go!
>
>  * Does RedirectPermenent sends the appropriate signal to whatever is
> requesting the domain, saying that this is a permanent thing?

Yes. Thus the permanent part of the name. ;)

See:
http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectpermanent

> Is that signal more appropriate than a mod rewrite, which doesn't  
> tell the web
> anything, but just redirects internally?\

When using mod_rewrite if you use the R=301 flag it does a redirect  
and sends a 301 status code. That's the exact same thing that  
RedirectPermanent does.

See:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_flags.html
http://www.addedbytes.com/cheat-sheets/download/mod_rewrite-cheat-sheet-v2.png

> * Does it require less processing?  Is it significantly less enough
> that it makes a difference when hosting hundreds of domains?

I've *heard* that mod_rewrite involved more processing, but I'm  
doubtful that it's enough to notice a difference. However, I don't  
have a server hosting several hundred domains, so I can't comment to  
that.

> * If it requires less processing, it's almost certainly faster to do a
> RedirectPermanent instead of a mod rewrite, but is it significantly
> faster, when hosting hundreds of domains on the same server?

I doubt it.

> * Is there less coding involved?

Not significantly less.

Because developers usually will not have the ability to modify (or  
even see) the httpd.conf file, I prefer to put the redirects  
in .htaccess. This means less tickets have to be filed to the server  
admins to make changes, fewer apache restarts for simple changes, and  
developers who better understand how their site actually works.

You also mentioned developers using full paths in their code. This is  
desirable for the SEO benefit in <a> tags (or so they say) but there's  
no reason to be *hard coding* those links when you can use  
$_SERVER['HTTP_HOST'] to get the current host and have the same links,  
and have them be right regardless of the environment.

If you're not doing that, how are you testing code before pushing it  
to production?

Brady


More information about the UPHPU mailing list