VPS侦探论坛

 找回密码
 注册
查看: 3907|回复: 3

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

[复制链接]
发表于 2018-4-6 20:25:28 | 显示全部楼层 |阅读模式

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


    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.*)$;
        try_files $uri =404;
        fastcgi_keep_conn on;
        fastcgi_pass  unix:/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 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-4-7 09:17:45 | 显示全部楼层


http://www.demo.com/admin/index.php/module/catalog 这种形式是pathinfo的
400不清楚,500的话只要你正常开启了php错误日志肯定就能记录下错误来
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 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
[07-Apr-2018 10:17:52 Europe/Madrid] PHP Fatal error:  Uncaught PDOException: SQLSTATE[42000]: 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 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 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;
        }
    }
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-24 09:25 , Processed in 0.025963 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表