Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've tried a lot of variations of config, but I still can't get it work as it should. Any suggestions?

 location ~ /views/(.+)\.php$ {
      deny all;
 }

Config:

server {
    listen       80;
    server_name  ...;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /srv/www;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    #    root           html;
     include        fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /srv/www$fastcgi_script_name;
    }


 if (!-e $request_filename){
    rewrite ^/([0-9]+)$ /get.php?get=$1 last;
    rewrite ^/add$ /add.php;
    rewrite ^/rss$ /rss.php;
 }

 location ~ /views/(.+)\.php$ {
    deny all;
 }
}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

URL match with another location. Post configure file.

Interchanging location(regular expressions are checked in the order defined in the configuration file):

location ~ /views/(.+)\.php$ {
 deny all;
}
location ~ \.php$ {
.....
share|improve this answer
1  
You probably also want to anchor the location regex at the root by starting it with ^ and there's no reason to capture anything if it's not going to be used (don't need the parentheses) –  kolbyjack Jan 26 '11 at 19:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.