View Full Version : no literal "?" in mod_rewrite regex? Or what's up?

09-01-2003, 08:41 PM
I'm using mod_rewrite to do "clean URLs", so a URL like "/site/portfolio/projects/" is rewritten into "?c=portfolio&s=projects".

So I've written this rule:

RewriteRule ^site/([a-z]+)[/]?([a-z]+)?[/]?([a-zA-Z=&]+)? /?c=$1&s=$2&$3

It's open ended so that something like "/site/portfolio/projects/foo=bar" can become "?c=portfolio&s=projects&foo=bar"

But that only works with manually generated URLs that don't have the "?" - I want to be able to use transient SID, and GET method forms, so it's gonna need to handle stuff like "/site/portfolio/projects/?foo=bar".

Okay ... so surely that's simply a case of adding a literal question mark into the expression:


But it doesn't work - everything after the "?" is lost. How come? Can I not have a literal question mark, or what's up?

09-01-2003, 09:04 PM
use the ascii code or html entitly for it.


09-01-2003, 11:26 PM
How do I do that - would "&#15" not be those four characters individually?

09-01-2003, 11:38 PM
a ? mark is & # 6 3 ;
without the spaces!


09-02-2003, 01:26 AM
Cool, I thought it was 15 .. but either way - how do I use that in a mod_rewrite regex? - an expression like


matches any one character out of "&", "#", "6", "3" or ";"

btw - you can do entities in the forum if you go ?