Forum Moderators: phranque

Message Too Old, No Replies

Rewriting the QUERY_STRING

Can it be done

         

calvinmicklefinger

7:27 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Can the Query String be re-written to pre-pend a slash?

Theoretically, something like ...

RewriteRule ^(%{QUERY_STRING})$ /$1

Which is not meant as a code sample, but as a conceptual goal.

Any help is appreciated.

jdMorgan

9:08 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you could do it. But this is a band-aid; Query strings usually don't start with slashes. If this were my site, I would fix the underlying problem -- the script should not expect a leading slash on a query string. It will probably be easier and certainly more efficient to fix it in the script, anyway.

We're sort of pushing into "What characters are valid in URLs?", and "What characters are valid in query strings?" territory here. The slash character is reserved for use in the URL, and a query string is not part of a URL. Rather, it is data appended to a URL to be passed to the resource at that URL. For best results, stick with the standards (RFC2396 [faqs.org]).

Jim

calvinmicklefinger

9:44 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Thanks for the guidance.

It is a problem with the script, but it was such a bugaboo to correct, I started looking for an easier way.

Found it just a moment ago with a RewriteRule that tests for the specifice URI requested and sends it out of the script, to come back at a later click.

Seems to work.

Thanks anyway. Your help is always appreciated.

It's fun learning the little parts of this I can catch on to, but it seems you really have to get immersed and be able to recollect as you go along. That part I'm getting weak on.