Multiple mod rewrites in .htaccess

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2010-12-29T14:43:59Z Indexed on 2010/12/29 14:54 UTC
Read the original article Hit count: 198

Filed under:
|
|

I want the following rules but I don't seem to get the right setup.

<domain>/training-courses/

both with or without the slash at the end it should go to:

<domain>/?index.php?page=training-courses

and for each variable extra after this I want it to behave like this:

<domain>/training-courses/success/another-value/and-yet-another/

to

<domain>/?index.php?page=training-courses&val1=success&val2=another-value&val3=and-yet-another-value

If it's not possible to have the option for unlimited leading variables, i'd like to have at least 2 variables after the page variable

Is this possible? and how do I get this sorted out?

I have this so far:

RewriteEngine On

RewriteRule ^test/([^/]*)/$ /test/index.php?pagina=$1&val1=$2
RewriteRule ^test/([^/]*)$ /test/index.php?pagina=$1&val1=$2

RewriteRule ^test/([^/]*)/([^/]*)/$ /test/index.php?pagina=$1&val1=$2
RewriteRule ^test/([^/]*)/([^/]*)$ /test/index.php?pagina=$1&val1=$2

RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)/$ /test/index.php?pagina=$1&val1=$2&val2=$3
RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)$ /test/index.php?pagina=$1&val1=$2&val2=$3

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about mod-rewrite