drupal 8在Nginx环境中update.php/selection 出现网页无法找到的解决方法

阿里ECS云服务器部署LNPM环境中的drupal 8,升级数据库update.php/selection 出现“网页无法找到”,找了好多资料终于找到解决方法,记录一下,修改/usr/local/nginx/conf/rewrite/drupal.conf

#if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php?q=$1 last;
#}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ \..*/.*\.php$ {
return 403;
}

location ~ (^|/)\. {
return 403;
}

location ~ ^/sites/.*/private/ {
access_log off;
deny all;
}

location / {
try_files $uri @rewrite;
}

location @rewrite {
rewrite ^ /index.php;
}

location ~ ^/(index|update)\.php(/|$) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_intercept_errors on;
}

location ~ ^/sites/.*/files/imagecache/ {
try_files $uri @rewrite;
}

location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

 

来源:https://www.drupal.org/project/drupal/issues/2353907

但是副作用出现了,所有网站的index.php默认页无效了。

 

再用回来原的并修改:

 

if (!-e $request_filename) {
rewrite ^/update.php(.*)$ /update.php?q=$1 last;
rewrite ^/(.*)$ /index.php?q=$1 last;
}

location ~ ^/(index|update)\.php(/|$) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_intercept_errors on;
}

 

location ~* \.(js|css|ico)$ {
expires max;
log_not_found off;
}

location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip)$ {

valid_referers none blocked  *.dscao.com localhost 47.96.14.208;
if ($invalid_referer) {
rewrite ^/ http://www.dscao.com/nolink.gif;
return 417;
break;
}
access_log off;
break;

}

完美解决!

发表评论