我有一个服务器(nginx/1.6.0 PHP 5.5.14)与这些设置工作正常。问题是当我使用location ^~ /sys/
当我尝试访问sys文件夹时,它下载索引。如果我删除location ^~/sys /
恢复正常工作。他错误只发生在PHP文件。 html文件正常工作。错误在哪里?Nginx的下载文件
server {
server_name site.com;
root /home/www/site.com;
index index.php index.html index.htm;
location/{
index index.php index.html;
try_files $uri $uri/ /index.php;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/data/php5514/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 300;
include fastcgi_params;
}
location ^~ /sys/ {
}
}
我正在使用脚本,需要在nginx中执行此设置以保护文件夹免受未经授权的访问。
location ^~ /FOLDER/ {
if ($cookie_amember_nr !~* [a-zA-Z0-9]+) { #not authorized
rewrite ^(.*)$ http://EXAMPLE.COM/AMEMBER/protect/new-rewrite?f=FOLDERID&url=$request_uri?$args redirect;
}
set $file $document_root/AMEMBER/data/new-rewrite/$cookie_amember_nr-FOLDERID;
if (!-f $file) { #have not access
rewrite ^(.*)$ http://EXAMPLE.COM/AMEMBER/no-access/folder/id/FOLDERID?url=$request_uri?$args redirect;
}
#everything is ok
}
但是location^~
这个问题不起作用。
有关**专业服务器或网络相关基础架构管理**的问题,除非直接涉及编程或编程工具,否则无法用于堆栈溢出。您可以在[服务器故障](http://serverfault.com/about)上获得帮助。 – icecub