...

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



brothercake
09-01-2003, 07: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:


^site/([a-z]+)[/]?([a-z]+)?[/]?[\?]?([a-zA-Z=&]+)?

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

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

scroots

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

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

scroots

brothercake
09-02-2003, 12: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 ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum