I am using this -

RewriteRule ^/one/([a-zA-Z-]+)/(two|TWO)/(three|THREE)/([a-zA-Z0-9()-.\?\=]*)/?$ /city/city-search.php?c=$1&t=$2&pf=$3&iptnr=$4

I am caling - www.winsoftwares.net/one/pune/two/three/index.php?ptnr=xyz and want to access variables in city-search.php like ... one , pune, two, three and ptnr value

but as string find '?' in (index.php?ptnr=xyz) it breaking....please help me

http://www.winsoftwares.net is not able to redirect this...


I don't think there's a way to examine the entire URL including parameters in one hit. You need to examine anything after the ? separately with a QUERY_STRING, eg.
RewriteCond %{QUERY_STRING} ^param=blah(.*) [NC]

| improve this answer | |
  • i use it its work for me but my parameter is not mandatory.... so what should i do..i use RewriteCond %{QUERY_STRING} ^ptnr=(.*)$ – Anuj Ji Aug 31 '10 at 12:22
  • If that's what you're looking for, to rewrite anything with a pntr parameter first (note that this will match more than one parameter but only if ptnr is first) then use this RewriteCond then have a RewriteRule underneath – James L Aug 31 '10 at 16:29

You have to escape the ? since it's a special character in regular expressions.

So instead of using ? try \?

| improve this answer | |
  • please check the above rewrite rule....already escaped – Anuj Ji Aug 31 '10 at 10:54

Normally you don't include the QUERY STRING in your matching pattern. Then you just add %{QUERY_STRING} to your rewrite rule. Example:

RewriteRule  ^/(articles)/([-a-z]+)-([0-9]+)/$  /index.php?cat=$1&id=$3&rewrite=$2&%{QUERY_STRING}

The Apache Documentation writes:

Note: Query String

The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable.

| improve this answer | |
  • thanks a lot dear..winsoftwares.net got started to respond now...its really great help today – Anuj Ji Aug 31 '10 at 14:19
  • No problem.. just vote me up if I helped you ;) – Jan. Aug 31 '10 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy