I am trying to redirect a login page to an external security service. This service, after validating the credentials, will then return user back to the originating page using the referrer url, as in the following example:
http://{IP NUMBER}/MyWiki/index.php?title=Special:UserLogin&returnto=Main_Page
or any call to a page in the site containing Special:UserLogin in the query_string needs to be redirected to:
https://login.security.server.com/test/UI/Login?service=DSSEC&goto=http://{IP NUMBER}/MyWiki/index.php/Special:UserLogin
I have been testing with RewriteCond and RewriteRule without any luck.
You want something like this?
Ok, this is going to seem a little confusing, but here’s what’s going on.
Special:UserLoginis in the request URI or the query string.?mark, the URI and the query string (this is very important)https://login.security.server.com/test/UI/Login, but using the back references from the previous condition to build thegoto=param, and using theBflag, which URL encodes the backreferences. This way, the result is an entire URL, along with query string, that’s been URL encoded. (TheNEflag is there to make sure the%signs themselves don’t get double encoded).With these rules, a request for:
Will get redirected to:
As you can see, the query string
?title=Special:UserLogin&returnto=Main_Pagegets encoded into%3ftitle%3dSpecial%3aUserLogin%26returnto%3dMain_Page, so that the login.security.server.com doesn’t mistake it for its own query string. Instead, their login service will see the goto parameter as:entirely intact.