[Rails] Avoid parsing URL in Apache conf?
Tobias Luetke
tobias.luetke at gmail.com
Fri Nov 19 16:18:41 GMT 2004
I personally like the mod_rewrite solution because it gives you low
level total control.
For example you can map subdomains to parameters for things like
"xal.mygallery.com".
However this is a special case and the rails philosophy is to make
common tasks easy, so i agree that we should look into moving it into
the framework.
As for mod rewrite:
One good option to avoid having 3 sets of rules is to use the
RewriteBase parameter.
This also helps with non virtual hosting ( aliases ).
example :
RewriteBase /dispatch.fcgi
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$
?controller=$1&action=$2&id=$3 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ ?controller=$1&action=$2 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/$ ?controller=$1&action=index [QSA,L]
This can easily changed into
RewriteBase /my/sub/directory/dispatch.rb
if required.
> Also, using mod_rewrite in a per directory setting is evil, and should,
> according to both Apache and mod_rewrite docs, be used only if there is
> absolutely no other alternative.
For which reason, Performance ?
--
Tobi
http://blog.leetsoft.com
More information about the Rails
mailing list