Allowing optional variables with Rewrite Cond

Posted by James Doc on Stack Overflow See other posts from Stack Overflow or by James Doc
Published on 2010-06-18T11:47:53Z Indexed on 2010/06/18 11:53 UTC
Read the original article Hit count: 379

Filed under:
|
|

I currently have the following code:

RewriteCond %{REQUEST_URI} !assets/
RewriteCond %{REQUEST_URI} !uploads/
RewriteRule ^([a-z|0-9_&;=-]+)/([a-z|0-9_&;=-]+) index.php?method=$1&value=$2 [NC,L]

This works perfectly to redirect 'page/home' to 'index.php?method=page&value=home. However at some points I need to add an extra variable or two to the query string such as 'admin/useraccounts/mod/2'. When I simply tack on bits to the end of the rewrite rule it works if all the variables are 'page/home/rand/rand' or 'admin/useraccounts/mod/2', but if anything is missing such as 'page/home' I get a 404.

What am I doing wrong?

Many thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about .htaccess