Help with specific redirect to https

Pete Ashdown pashdown at xmission.com
Wed Dec 12 16:58:11 UTC 2012


On 12/12/2012 09:48 AM, Antonio P.P. Almeida wrote:
>> 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;
>>   }
> 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;
> }

Thanks for your attempt, but this failed as well.

Pete



More information about the nginx mailing list