我唯一做的就是
mv test.php betterName.php 没有权限的改变,什么都没有改变。它们在NGINX配置中重命名..。从…
location @rule {
rewrite ^rule([a-z0-9]+)$
/test.php?obj=$1 last;
}至
location @rule {
rewrite ^rule([a-z0-9]+)$
/betterName.php?obj=$1 last;
}和service nginx restart。
这是神奇的:当我“撤销”重命名进程,mv betterName.php test.php和返回旧位置,所有的工作再次良好。
使用新鲜UBUNTU 16 LTS与新鲜的NGINX。
备注
我使用的现实生活中的conf-nginx脚本,
server {
server_name etc.etc;
access_log /var/log/nginx/etc.etc.access_log;
root /var/www/etc.etc/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ @idResolver;
}
location ^~ /issn {
try_files $uri @issnResolver;
}
location @idResolver {
rewrite ^/?([a-zA-Z0-9\-]+)/?$
/index.php?obj=$1 last;
}
location @issnResolver {
rewrite ^/?issn[/:]?([xX0-9\-]+)[/:]?([a-zA-Z0-9]+)$
/test.php?obj=$1&cmd=$2 last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
} #end server..。@RichardSmith评论的更多现实生活垃圾:
ll /var/www/etc.etc/
drwxr-xr-x 7 www-data www-data 4096 Feb 15 09:41 ./
drwxr-xr-x 4 www-data www-data 4096 Feb 9 09:07 ../
-rw-rw-r-- 1 www-data www-data 5860 Feb 14 21:04 index.php
-rw-rw-r-- 1 www-data www-data 291 Feb 15 09:24 test.php现实生活中的名字是issn_resolver.php,所以我做了mv test.php issn_resolver.php。
发布于 2018-02-15 12:10:54
URI /issn_resolver.php将匹配location ^~ /issn块,而不是预期的location ~ \.php$块。这将导致下载而不是执行PHP脚本。
^~运算符使前缀位置比所有正则表达式位置块具有更高的优先级。
如果^~操作符是不必要的--删除它--否则,为PHP脚本找到一个不以issn开头的名称。
有关更多信息,请参见本文件。
若要将以issn开头的所有URI重定向到给定的脚本,请执行以下操作:
1)将两个locations组合为一个,并使用一个不以issn开头的PHP脚本名
location ^~ /issn {
rewrite ^/?issn[/:]?([xX0-9\-]+)[/:]?([a-zA-Z0-9]+)$
/test.php?obj=$1&cmd=$2 last;
}或者:
2)硬连接PHP文件的名称:
location ^~ /issn {
rewrite ^/?issn[/:]?([xX0-9\-]+)[/:]?([a-zA-Z0-9]+)$
/?obj=$1&cmd=$2 break;
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $document_root/test.php
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}注意,rewrite...break用于捕获PHP脚本的查询字符串,但不再需要为脚本文件命名。脚本文件是通过重写从SCRIPT_FILENAME文件导入的值来命名的。
https://stackoverflow.com/questions/48804292
复制相似问题