Page 1 of 1

Dealing with question marks????????

Posted: Sun Oct 16, 2005 6:01 pm
by BigChase
Trying to create a .htaccess RewriteRule that will map

question.php?1 to query?number=1

but niether of the following ways to deal with the '?' (question mark) work:

RewriteRule ^question \.php\?1$ query?number=$1
RewriteRule ^question \.php$?^([0-9])$ query?number=$1

How do I deal with the question mark in the pattern without having the regular expression mistake the '?' in the URL as the ? operator?

Thank you.

Posted: Sun Oct 16, 2005 6:40 pm
by Ambush Commander

Code: Select all

"/\? \(escape it\)/"

Posted: Sun Oct 16, 2005 7:32 pm
by BigChase
Sorry, I don't know how to read your response. Can you insert it in the example in the original posting. Sorry to be so thick. Thanks.

Posted: Sun Oct 16, 2005 7:34 pm
by Todd_Z
\?

Posted: Sun Oct 16, 2005 7:35 pm
by Ambush Commander

Code: Select all

RewriteRule ^question \.php\?1$ query\?number=$1

Posted: Mon Oct 17, 2005 3:19 am
by BigChase
It didn't work when I escaped the question mark, but I see in addition you:

escaped the '.' AND added a space after 'question'

Are both of those necessary?

Thanks.

Posted: Mon Oct 17, 2005 8:09 am
by Chris Corbyn

Code: Select all

RewriteRule     ^question\.php\?([0-9]+)$     query?number=$1
On the left hand side the ^ and $ mean start and end of string. On the right hand side the $ means backreferece (i.e. the bit in the parens on the left).

You pretty much had it right although needed to add a backslash before "?" on the left and also remove some carets and dollars :D