regex problem

15 views
Skip to first unread message

Ben Carlson

unread,
May 9, 2012, 10:50:48 PM5/9/12
to UrlRewrite
I am trying to convert this url:

/api/authenticate/<userId>?password=<password>

to the following:

/api/auth/loginSimple.jsp?login=<userId>&password=<password>

With the following, I've been able to get the userId populated, but
after about 20 tries, I still cannot pull the password out.


<rule>
<from>^/authenticate/([^/].*?)(/.*)*$</from>
<to type="forward">/auth/loginSimple.jsp?login=$1&amp;password=$2</
to>
</rule>

Additionally, I've enlisted the help of a very smart guy who has been
messing about with regex for years, and he says the following tests
fine against the java regex library:

.*?/authenticate/([^/?]*).*?=(.*)

But I'm unable to get it to work (in fact, it doesn't even forward to
the /api/auth/loginSImple.jsp url, it just gives a 404. It seems that
in this instance, and several others, we are unable to get two
variables to parse out of the <from> string.

Any help would be much appreciated! Thanks!

-Ben

Wim De Smet

unread,
May 10, 2012, 4:19:44 AM5/10/12
to urlre...@googlegroups.com
This is probably a filter configuration issue. Try setting the type to
"redirect" and see if that works.

If it does, you need to be listening to internal forwards and aren't.
Search the docs for "FORWARD" (there are also a bunch of mails on this
list about it). You can get a better idea of what is happening with
the filtering by enabling logging (also explained in the docs), to
make sure it is actually firing on your rule or not.

BTW, I don't mean to pry, but you realise putting the password in the
URL is not exactly considered a best practice?

regards,
Wim

benca...@gmail.com

unread,
May 10, 2012, 7:08:37 AM5/10/12
to urlre...@googlegroups.com
Thanks for the pointers... I'll dig in. Oh, and yes... pwd in url is not ideal, but it's how the tool that will call this service is written. <sigh>

-Ben

>--
>You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
>To post to this group, send email to urlre...@googlegroups.com.
>To unsubscribe from this group, send email to urlrewrite+...@googlegroups.com.
>For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en.
>

Reply all
Reply to author
Forward
0 new messages