views:

53

answers:

2

I wonder if my .htaccess file is too long/inefficient?
I have about 250 lines of rewrite rules like:

RewriteRule ^(en|de|fr)/foobar$ ?site=foobar&lang=$1 [L]  
RewriteRule ^(en|de|fr)/foobar/bar/123$ ?site=foobar&value=bar&othervalue=$2&lang=$1 [L]

Is there a way to do it more efficiently?

+3  A: 

Yes, process the strings inside PHP instead. There's really no point in having quite so much of your application logic in .htaccess, especially considering the performance overhead.

Replace the whole lot, or as much as you can, with something like:

RewriteRule ^([-A-Za-z0-9/]+)$    index.php?q=$1   [NC,L,QSA]

and start learning to love explode() :) ( and list()! - thanks mecu!)

danp
Be sure to also love `list()`, it goes very well with `explode()`
MECU
A: 

You could always change the layout of your site to work more like you're making it work.

Chad