dousi1875 2019-05-01 09:36
浏览 121

从PHP 7.2下的NGINX 1.12下运行的Symfony 4应用程序中删除public / index.php / url

I would like to remove the public/index.php/ part of a url from a Symfony 4 app running on Nginx 1.12

I have followed the default Symfony webserver setup here https://symfony.com/doc/current/setup/web_server_configuration.html#nginx but to no avail

server {
    server_name  _;
    root /usr/share/nginx/html/app/public;
    error_log /var/log/nginx/app_error.log;
    access_log /var/log/nginx/app_access.log;

    charset utf-8;
    client_max_body_size 0;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_read_timeout 600;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
        return 404;
    }
}
  • 写回答

1条回答 默认 最新

  • dongmian5325 2019-05-02 13:46
    关注

    Have you see in Symfony Docs Official : https://symfony.com/doc/current/setup/web_server_configuration.html

    Lot of information for web server with Nginx is here.

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?