UrlRewrite with query string

6 views
Skip to first unread message

whostheJBoss

unread,
Jun 25, 2009, 12:29:08 PM6/25/09
to UrlRewrite
I don't see my post showing up in the discussion, so if this goes in
twice, I'm sorry!

I have my rules set up to catch anything after a / and redirect it to
index.php with a PATH_INFO variable. The index.php

reads the PATH_INFO variable and makes the appropriate decision about
routing to events.

I have other specific rules in addition to this one, but here is the
catch-all:

<rule>
<from>^/(.*)$</from>
<to last="true">/index.php?PATH_INFO=$1</to>
</rule>

So, this works for:

http://mysite.com/someaction/somethingelse (redirects to
http://mysite.com/index.php?PATH_INFO=someaction/somethingelse)
http://mysite.com/index.php/someaction/somethingelse (redirects to the
same as the one above)
The index.php parses PATH_INFO and pulls out my variables for use in
PHP. The problem is that I need certain variables to be

available before the parse, such as debug, etc

I can pass variables such as:

http://mysite.com/someaction/somethingelse/id/1 (id=1) or
http://mysite.com/someaction/somethingelse/id/1/myname/test (id=1,

myname=test) and they work fine.

However, http://mysite.com/someaction/somethingelse/?id=1 does not
pick up the ID variable

If I use http://mysite.com/someaction/somethingelse/&id=1 it does...

So, I basically need a way for all of my rewrites to first detect if
there is a query string, then rewrite everything before

the querystring by the rule and attach the query string onto that.

I need to be able to do this:

http://mysite.com/someaction/somethingelse/?debug=yes
http://mysite.com/someaction/somethingelse/?id=1&myname=test

and have them redirect to:

http://mysite.com/index.php?PATH_INFO=someaction/somethingelse&debug=yes

So, I need the query string added on to the end of any request if it
exists. Right now my rule simply passes everything

after the / as the PATH_INFO variable.

My rules are here:

<rule>
<from>^/index.php/(.*)$</from>
<to last="true">/index.php?PATH_INFO=$1</to>
</rule>

<rule>
<from>^/(.*)$</from>
<to last="true">/index.php?PATH_INFO=$1</to>
</rule>

<rule>
<from>/(.*)$</from>
<to last="true">/index.php?PATH_INFO=$1</to>
</rule>

Any ideas???

whostheJBoss

unread,
Jun 25, 2009, 11:55:45 AM6/25/09
to UrlRewrite
Reply all
Reply to author
Forward
0 new messages