Basic Authentication and PHP files

Ellimist nginx-forum at
Tue Feb 15 18:26:29 MSK 2011

I have a configuration block like this :

	location /members/ {
		index  main.php;

	location ~ ^/members/(?:text1|text2|text3)/(?!noinclude)[^\/]+/ {
		auth_basic            "Restricted Area";
		auth_basic_user_file  /home/password/.htpasswd;
		rewrite ^\/(members\/[^\/]+\/[^\/]+)\/$ /gallery.php?path=$1&page=1
		rewrite ^\/(members\/[^\/]+\/[^\/]+)\/page([0-9]+)\.php$
/gallery.php?path=$1&page=$2 last;

        location ~ \.php$ {
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME 
                include fastcgi_params;


The problem is that whenever I go to or, it correctly
displays the redirected page from gallery.php correctly, but it requires
no authentication. The images and other elements embedded on the page
from within the directory requires authentication, however.

I'm using v0.8.54.

Posted at Nginx Forum:,175467,175467#msg-175467

More information about the nginx mailing list