zhiyi_cai 发表于 2018-4-6 20:25:28

prestashop nginx conf 后台某些网页提醒400 如何解决??

Prestashop nginx conf 后台某些网页提醒400 如何解决??

server {
    listen 80;
    #listen [::]:80;
    server_name www.demo.com demo.com;
    index index.html index.htm index.php default.html default.htm default.php;
    root/www/web/demo;

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

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

    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
      deny all;
      access_log off;
      log_not_found off;
    }

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 1;
    gzip_buffers 16 8k;
    gzip_http_version 1.0;
    gzip_types application/json text/css application/javascript;

    rewrite ^//(index\.php.*)$ /$1 last;#Remove language code when index.php is called directly
    rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
    rewrite ^/()(-*)?(-+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
    rewrite ^/()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
    rewrite ^/()()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
    rewrite ^/()()()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
    rewrite ^/()()()()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
    rewrite ^/()()()()()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
    rewrite ^/()()()()()()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
    rewrite ^/()()()()()()()()(-*)?(-+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
    rewrite ^/c/(+)(-[.*_a-zA-Z0-9-]*)(-+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
    rewrite ^/c/(+)(-+)?/.+.jpg$ /img/c/$1$2.jpg last;


    location ~ .php$ {
      fastcgi_split_path_info ^(.+.php)(/.*)$;
      try_files $uri =404;
      fastcgi_keep_conn on;
      fastcgi_passunix:/tmp/php-cgi.sock;
      fastcgi_index index.php;
      include /usr/local/nginx/conf/fastcgi.conf ;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
}


提示 400错误 》 http://www.demo.com/admin/index.php/module/catalog?_token=zBZuz_fhR_OOaCO9m_wq7_IlOZrSgQ5PM4bm4C5XQZU
提示 400错误 》 http://www.demo.com/admin/index.php/product/catalog?_token=3gjswiORMA0k5az0d5RfQsyqBtWVAAADudgEVdsLGnc

正常访问 》 http://www.demo.com/admin/index.php?controller=AdminThemes&token=28d5e94d44e8368b660b43bf0a80f2a7
正常访问 》 http://www.demo.com/admin/index.php?controller=AdminOrders&token=3ebac796e3e90aac979072caef7b08f1




index.php/product/catalog?_token= 这样格式 提醒400 或者 500错误
index.php?controller=AdminOrders&token 这样格式可以正常访问


这个问题如果解决呢? 麻烦告知一下 谢谢

[ 本帖最后由 zhiyi_cai 于 2018-4-7 07:29 编辑 ]

licess 发表于 2018-4-7 09:17:45

http://www.demo.com/admin/index.php/module/catalog 这种形式是pathinfo的
400不清楚,500的话只要你正常开启了php错误日志肯定就能记录下错误来

zhiyi_cai 发表于 2018-4-7 16:40:00

回复 2# 的帖子

您好 军哥 又要麻烦您看一下, 我弄了好几个小时了 根本没一点头绪。
也在Google 百度,找了很多讯息 都尝试了一下,都没用,
404 Not Found 错误
http://www.demo.com/admin/index.php/module/catalog?_token=3gjswiORMA0k5az0d5RfQsyqBtWVAAADudgEVdsLGnc

php_errors.log
Stack trace:
#0 /www/web/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(105): PDOStatement->execute(NULL)
#1 /www/web/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(847): Doctrine\DBAL\Driver\PDOStatement->execute()
#2 /www/web/demo/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(50): Doctrine\DBAL\Connection->executeQuery('SELECT p0_.id_t...', Array, Array, NULL)
#3 /www/web/demo/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(321): Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(Object(Doctrine\DBAL\Connection), Array, Array)
#4 /www/web/demo/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962): Doctrine\ORM\Query->_doExecute()
#5 /www/web/demo/vendor/doctrine/orm in /www/web/demo/app/bootstrap.php.cache on line 3231
PHP Fatal error:Uncaught PDOException: SQLSTATE: Syntax error or access violation: 1139 Got error 'this version of PCRE is compiled without UTF support at offset 0' from regexp in /www/web/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105

[ 本帖最后由 zhiyi_cai 于 2018-4-7 16:41 编辑 ]

zhiyi_cai 发表于 2018-4-7 17:21:23

解决方法

解决方法:
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括perl兼容的正则表达式库。这些在执行正则表达式模式匹配时用与Perl 5同样的语法和语义是很有用的,也可以来解决C语言中使用正则表达式的问题。

PCRE下载地址:https://sourceforge.net/projects/pcre/files/pcre/

重新编译安装pcre:

1、下载pcre-8.39.tar.gz
2、解压
# tar zxvf pcre-8.39.tar.gz
# cd pcre-8.39
3、编译安装(指定:--enable-utf8 --enable-unicode-properties )

# ./configure --enable-utf8 --enable-unicode-properties
# make
# make install


当安装好pcre后,利用pcretest命令来打印pcre的安装情况,一般输出如下:

复制代码
# pcretest -C
PCRE version 8.39 2016-11-23
Compiled with
8-bit support
UTF-8 support
Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Parentheses nest limit = 250
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack


然后在conf 加入:
    location /admin/ {                           #Change this to your admin folder
      if (!-e $request_filename) {
            rewrite ^/.*$ /admin/index.php last;   #Change this to your admin folder
      }
    }
    location / {
      if (!-e $request_filename) {
            rewrite ^/.*$ /index.php last;
      }
    }
页: [1]
查看完整版本: prestashop nginx conf 后台某些网页提醒400 如何解决??