centos下配置nginx使其支持tp5的pathinfo,隱藏入口文件

location / {
    root    $root;
    index    index.html index.php;
    if ( -f $request_filename) {
        break;
    }
    if ( !-e $request_filename) {
        rewrite ^(.*)$ /index.php/$1 last;
        break;
    }
}
location ~ .+\.php($|/) {
    set $script $uri;
    set $path_info "";
    if ($uri ~ "^(.+\.php)(/.+)") {
        set $script $1;
        set $path_info $2;
    }
    fastcgi_pass    unix:/run/php/php7.0-fpm.sock;
    fastcgi_index    index.php?IF_REWRITE=1;
    fastcgi_param    PATH_INFO    $path_info;
    fastcgi_param    SCRIPT_FILENAME    $root$fastcgi_script_name;
    fastcgi_param    SCRIPT_NAME    $script;
    include        fastcgi_params;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章