I hope this is more clear.
With this URL:
http://www.mysite.com/ms/create/?debugmode=true&debugpass=password
How can I write a rule that will match and rewrite it to:
http://www.mysite.com/index.php?PATH_INFO=ms/create/&debugmode=true&debugpass=password
-------------
-------------
I want to make sure that any of the following URLS would do the same:
http://www.mysite.com/ms/create?debugmode=true&debugpass=password
To:
http://www.mysite.com/index.php?PATH_INFO=ms/create/&debugmode=true&debugpass=password
I have these next ones working, they are last in the rule list, so I
really just need the first two figured out, so that they will fire
before the chain reaches these next two.
THIS: ----
http://www.mysite.com/?debugmode=true&debugpass=password
To:
http://www.mysite.com/index.php?PATH_INFO=&debugmode=true&debugpass=password
----
AND:
----
http://www.mysite.com/?debugmode=true&debugpass=password
To:
http://www.mysite.com/index.php?PATH_INFO=&debugmode=true&debugpass=password
Basically, I need anything that has a query string (a question mark, ?
=this=that or ?whatever=something&more=less) to redirect to:
http://www.mysite.com/index.php passing anything before the ? as
PATH_INFO and anything after as ?=variable=value&variable2=value2, etc
The following rule achieves the first two examples I need:
<rule>
<from>^/\?(.*)$</from>
<to last="true">/index.cfm?$1</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>
(the set elements are not necessary, they are just there for me to use
later)
However, trying this rule will not match the last two I need, such as
whatever/whatever/?something=value
<rule>
<from>^/\?(.*)$</from>
<to last="true">/index.cfm?$1&match=1</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>
It ends up matching something like this:
http://www.mysite.com/ms/create/?debugmode=true&debugpass=password
To this rule:
<rule>
<from>^/(.*)$</from>
<to last="true">/index.cfm?PATH_INFO=$1&match=2</to>
<set name="urlrewrite.originalRequestUri">%{request-uri}</set>
<set name="urlrewrite.originalQueryString">%{query-string}</set>
</rule>
And redirecting to:
http://www.mysite.com/index.php?PATH_INFO=ms/create/?debugmode=true&debugpass=password
Instead of:
http://www.mysite.com/index.php?PATH_INFO=ms/create/&debugmode=true&debugpass=password
It matches everything from /ms... on, including the ? as $1
I can add this:
&%{query-string}to the end of this line:
<to last="true">/index.cfm?PATH_INFO=$1&match=2&%{query-
string}</to>
Then I can get the query original query string, but the PATH_INFO
contains the wrong information, it has the info I need PLUS the extra
query string information. With the query string added to the end, it
attempts to go to this URL:
http://www.mysite.com/index.php?PATH_INFO=ms/create/?debugmode=true&debugpass=password&debugmode=true&debugpass=true
So, since there is a ? in the PATH_INFO variable, it treats that as
part of the variable, but the & breaks the variable and starts a new
one with debugpass. The problem is that the appended query string also
contains debugpass, so I end up with the value
debugpass=password,password not debugpass=password
So, I need a way to match everything before the ? as PATH_INFO so that
I can append the query string without getting a duplicate.
How can I match everything before ? as PATH_INFO and everything
after ? as the query string?
Thanks! I have been tearing my hair out over this!