【问题标题】:Nginx Laravel Route as CodeigniterNginx Laravel 路由作为 Codeigniter
【发布时间】:2016-07-29 16:03:53
【问题描述】:

我有一个 Laravel 5 项目,可以从 testing.com/staffs 访问人员信息,但我想将 URL 更改为 testing.com/test/index.php/staffs,我尝试了 Laravel Route 组使用“test/index.php/”,但是laravel不支持路由中的“dot”,我该怎么做?

以下是我的部分 nginx.conf

location / {
        try_files $uri $uri/ /index.php?$args;

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9006;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

【问题讨论】:

  • 您似乎缺少fastcgi_split_path_info ^(.+?\.php)(/.*)$;。见this document。
  • 您是否尝试为您的路线添加前缀? Route::group(['prefix' => 'test/index.php'], function() { /* your route here ... */ });
  • shempignon : Laravel 不支持 dot in route::group 前缀

标签: php codeigniter laravel nginx


【解决方案1】:

我认为 Rickard Smith 可能是对的!以下是finally代码

location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass    127.0.0.1:9006;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
}

那么您现在可以使用带有“点”的路由组前缀,感谢 Rickard Smith 和 shempignon 帮助!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-11
    • 2019-10-22
    相关资源
    最近更新 更多