关于nginx下drupal7无法$_GET获取参数的问题

参考:nginx 官方drupal 配置 - Drupal | NGINX

之前配置好了LNMP下的drupal7(7.59版本),简洁路径也配好了。但是在使用过程出现问题。

配置的nginx.conf如下:

 1 server {
 2         listen       80;
 3         server_name  drupal759.com;
 4      index index.html index.htm index.php;
 5         root  /home/wwwroot/drupal759;
 6         include enable-php.conf;
 7 
 8     location / { #drupal启用简介路径
 9             try_files   $uri $uri/ /index.php;
10         }
11     
12       location /nginx_status
13         {
14             stub_status on;
15             access_log   off;
16         }
17 
18         location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
19         {
20             expires      30d;
21         }
22 
23         location ~ .*.(js|css)?$
24         {
25             expires      12h;
26         }
27 
28         location ~ /.well-known {
29             allow all;
30         }
31 
32         location ~ /.
33         {
34             deny all;
35         }
36 
37         access_log  /home/wwwlogs/access.log;
38     }
View Code

最典型的的问题,就是使用pathauto模块,进行配置了路径时,页面“admin/config/search/path/patterns”下有“Browse available tokens.”这种超链接:

但是当我单击时,该超链接没有反应,F12观察,显示没有权限访问该菜单。

菜单链接是“token/tree?options=xxxx&token=xxxx”

毙了狗,我可是管理员角色(uid=1),还有什么页面是我没权限的。

去看了下token.module文件:

$items['token/tree'] = array(
    'page callback' => 'token_page_output_tree',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'token.pages.inc',
    'theme callback' => 'ajax_base_page_theme',
  );

菜单没有权限啊( 'access callback' => TRUE,是访问不受任何限制的)。

那只能知“token_page_output_tree”的问题了,看了下

只有第56行有访问拒绝的代码(return MENU_ACCESS_DENIED;)。

var_dump测试了一下if的条件,惊奇发现,$_GET['token']竟然没有获取到!!!

进而直接取$_GET直接var_dump,结果就呵呵了:

 看到了吗,只取到路径,没有参数options和token!!!

恩,在网上搜了半天,这个问题,终于找到原因,是我的nginx.conf配置的问题,解决办法:

将try_files项改为:

   location / { 
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

保存修改后的nginx.conf,然后

nginx -s reload #重启nginx

再试一下。ok啦~

原文地址:https://www.cnblogs.com/zjfblog/p/9212687.html