Welcome! Log In Create A New Profile

Advanced

Re: Basic Auth not requested when rewrite rule exists

merlin corey
December 24, 2009 01:04AM
On Wed, Dec 23, 2009 at 2:24 AM, Dave Kennard <showerheadsuk@hotmail.com> wrote:
> Part of my Server config looks like this:
> location /admin/ {
>         auth_basic            "Restricted";
>         auth_basic_user_file  /path/to/.htpasswd;
>
>         #rewrite any .xhtml page to page.php
>         rewrite ^/(.+)\.xhtml$ /$1.php last;
>     }
>
> But when I go to mysite.com/admin/somefile.xhtml I don't get asked for
> Authentification and the page will display.
>
> If I comment out the rewrite rule then I do get asked for authentification.
>
> Can anyone advise me on how to get authentification and the rewrite rule
> working together?
>
> Thanks
>
> Dave
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
>

Hello,

You rewrite the request to something.php which is likely handled by a
separate location that captures all PHP. You should make a PHP
location internal to the location in question. In one of two ways...

Outside of admin like so:
location /admin {
auth_basic ...;
...
}
location ~ ^/admin/.*\.php {
auth_basic ...;
...
}

Inside admin like so:
location /admin {
auth_basic ...;
location ~ \.php$ { ... }
}

Thanks,
Merlin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Basic Auth not requested when rewrite rule exists

Dave Kennard December 23, 2009 05:28AM

Re: Basic Auth not requested when rewrite rule exists

merlin corey December 24, 2009 01:04AM

Re: Basic Auth not requested when rewrite rule exists

Dave Kennard December 25, 2009 10:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready