.htaccess & mod_rewrite for passing GET parameters

Currently I use this to pass GET parameters on an "elegant" way:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/$                       index.php?module=$1                        [L]
RewriteRule ^([^/]*)/([^/]*)/$               index.php?module=$1&object=$2              [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$       index.php?module=$1&object=$2&submodule=$3 [L]

This works great for 3 parameters max., (and I'm sure it's seriously ugly).

Any way to do the same thing, for n-paremeters?

Upvotes: 0

Views: 3932

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799470

Use either:

RewriteRule ^(.*)/$ index.php?path=$1

or

RewriteRule ^(.*)/$ index.php/$1

and tear apart $_GET['path'] or $_SERVER['PATH_INFO'] respectively.

Upvotes: 1

Related Questions