I'm trying to redirect anyURL that contains "UserLogin" (ie: Mediawiki) to https. This is what I've tried: rewrite .*UserLogin.* https://domain.com$request_uri? permanent; ---- rewrite UserLogin https://domain.com$request_uri? permanent; ---- rewrite ^.*UserLogin.*$ https://domain.com$request_uri? permanent; ---- location ~* .*UserLogin.* { return 301 https://domain.com$request_uri; } ---- location ~ .*UserLogin.* { return 301 https://domain.com$request_uri; } All of them have no effect. I'm running out of trial to match my error. Can anyone tell me what I'm doing wrong? Thank you.
on 2012-12-12 17:14
on 2012-12-12 17:49
> return 301 https://domain.com$request_uri; > } > ---- > location ~ .*UserLogin.* { > return 301 https://domain.com$request_uri; > } At the http level: map $uri $redirect_https { default 0; ~^.*UserLogin.*$ 1; } Then at the server level do: if ($redirect_https) { return 301 https://$host$request_uri; } --appa
on 2012-12-12 17:59
On 12/12/2012 09:48 AM, Antonio P.P. Almeida wrote: >> return 301 https://domain.com$request_uri; > } > > Then at the server level do: > > if ($redirect_https) { > return 301 https://$host$request_uri; > } Thanks for your attempt, but this failed as well. Pete
on 2012-12-12 18:14
On Wed, Dec 12, 2012 at 09:13:27AM -0700, Pete Ashdown wrote: Hi there, > I'm trying to redirect anyURL that contains "UserLogin" (ie: Mediawiki) to > https. This is what I've tried: Can you show one example request that you would like to have redirected? In nginx, the query string part of the request may not be matched when you might expect it to be. f -- Francis Daly francis@daoine.org
on 2012-12-12 19:08
> Thanks for your attempt, but this failed as well.
What's the exact structure of your URI?
If it's an argument then there are several approaches. For starters this
should work (but it's ugly :) to improve it we need further details).
map $request_uri $redirect_https {
default 0;
~*^.*UserLogin.*$ 1;
}
--appa
on 2012-12-12 20:23
On 12/12/2012 11:07 AM, Antonio P.P. Almeida wrote: > } This is what it looks like via Mediawiki. The &returnto argument is dependent on where the Login button is hit, and may or may not be present. http://domain.com/index.php?title=Special:UserLogi...
on 2012-12-12 23:30
On 12 Dez 2012 20h22 CET, pashdown@xmission.com wrote: >> default 0; >> ~*^.*UserLogin.*$ 1; >> } > > This is what it looks like via Mediawiki. The &returnto argument is > dependent on where the Login button is hit, and may or may not be > present. > > http://domain.com/index.php?title=Special:UserLogi... Try: map $arg_title $redirect_https { default 0; Special:UserLogin 1; } --- appa
on 2012-12-13 00:43
On Wed, Dec 12, 2012 at 12:22:51PM -0700, Pete Ashdown wrote: Hi there, > This is what it looks like via Mediawiki. The &returnto argument is > dependent on where the Login button is hit, and may or may not be present. > > http://domain.com/index.php?title=Special:UserLogi... In nginx terms, for this request, $uri = /index.php. $uri is what both "rewrite" and "location" match against. That is why the first few attempts did not do what you hoped they would. Some other variables which are available include: $request_uri = /index.php?title=Special:UserLogin&returnto=Main+Page $args = title=Special:UserLogin&returnto=Main+Page $arg_title = Special:UserLogin So you can do an exact or regex match of any of those in a "map" to set another variable; or you can match directly in an "if"; and then return the redirection. All the best, f -- Francis Daly francis@daoine.org
on 2012-12-13 18:04
On 12/12/2012 03:30 PM, Antnio P. P. Almeida wrote: >>> map $request_uri $redirect_https { > map $arg_title $redirect_https { > default 0; > Special:UserLogin 1; > } > Thank you Antonio. This works perfectly.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.