views:

88

answers:

1

Problem: See examples below. When using mod_rewrite to put "the URI part after the script name" into the query string (in any way), the ending periods (.) of every "directory" are removed. (Apache 2.2.14 on win32.)

Question: Is there any way to solve this or do I have to parse REQUEST_URI?

Request ("."s escaped):

http://localhost/simp.fcgi/fo%2eo%2e=12%2e3%2e/ba%2eh%2e%2e%2e/baz%2e?foo%2e=bar%2e

(Always get REQUEST_URI: /simp.fcgi/fo.o.=12.3./ba.h.../baz%2e?foo%2e=bar%2e)

RewriteRule ^simp.fcgi/(.*)$ simple.fcgi?qs=$1
Got      QUERY_STRING: qs=fo.o.=12.3/ba.h/baz
Expected QUERY_STRING: qs=fo.o.=12.3./ba.h.../baz.
      or QUERY_STRING: qs=fo%2eo%2e=12%2e3%2e/ba%2eh%2e%2e%2e/baz%2e

RewriteRule ^simp.fcgi/(.*)$ simple.fcgi?qs=$1 [NE]
Got      QUERY_STRING: qs=fo.o.=12.3/ba.h/baz
Expected QUERY_STRING: qs=fo.o.=12.3./ba.h.../baz.
      or QUERY_STRING: qs=fo%2eo%2e=12%2e3%2e/ba%2eh%2e%2e%2e/baz%2e

RewriteRule ^simp.fcgi/(.*)$ simple.fcgi?qs=$1 [QSA]
Got      QUERY_STRING: qs=fo.o.=12.3/ba.h/baz&foo%2e=bar%2e
Expected QUERY_STRING: qs=fo.o.=12.3./ba.h.../baz.&foo%2e=bar%2e
      or QUERY_STRING: qs=fo%2eo%2e=12%2e3%2e/ba%2eh%2e%2e%2e/baz%2e&foo%2e=bar%2e

Request ("."s not escaped):

http://localhost/simp.fcgi/fo.o.=12.3./ba.h.../baz.?foo.=bar.

(Always get REQUEST_URI: /simp.fcgi/fo.o.=12.3./ba.h.../baz%2e?foo.=bar.)

RewriteRule ^simp.fcgi/(.*)$ simple.fcgi?qs=$1 [QSA]
Got      QUERY_STRING: qs=fo.o.=12.3/ba.h/baz&foo.=bar.
Expected QUERY_STRING: qs=fo.o.=12.3./ba.h.../baz.&foo.=bar.

RewriteRule ^simp.fcgi/(.*)$ simple.fcgi?qs=$1
Got      QUERY_STRING: qs=fo.o.=12.3/ba.h/baz
Expected QUERY_STRING: qs=fo.o.=12.3./ba.h.../baz.

RewriteRule ^simp.fcgi/(.*)$ simple.fcgi?qs=$1 [NE]
Got      QUERY_STRING: qs=fo.o.=12.3/ba.h/baz
Expected QUERY_STRING: qs=fo.o.=12.3./ba.h.../baz.
+1  A: 

Try to get the value from THE_REQUEST instead:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /simp\.fcgi/([^?\ ]*)
RewriteRule ^simp\.fcgi/ simple.fcgi?qs=%1 [QSA]
Gumbo
That works. It also works to use REQUEST_URI, which yields a bit simpler expression:RewriteCond %{REQUEST_URI} ^/simp\.fcgi/(.*)RewriteRule ^simp\.fcgi/ simple.fcgi?qs=%1
Qtax