Basic Auth not requested when rewrite rule exists
merlin corey
merlincorey at dc949.org
Wed Dec 23 22:08:29 MSK 2009
On Wed, Dec 23, 2009 at 2:24 AM, Dave Kennard <showerheadsuk at 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 at 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
More information about the nginx
mailing list