友好的URL nginx修复

时间:2018-09-26 17:03:58

标签: nginx friendly-url

我对友善网址有疑问。以下脚本可以正常运行,但目前不像
/index.php有用
/index有用
/index/不起作用(我希望它可以与/index打开同一页面)
如何解决这个问题?

location / {
    autoindex on;
    root   /var/www/plasti;
    index index.php index.html index.htm;
    if ($request_uri ~ ^/(.*)\.php$) {  return 302 /$1;  }
    try_files $uri $uri/ $uri.html $uri.php?$args;
}

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    #fastcgi_connect_timeout 300s;
    fastcgi_read_timeout 120s;
    #fastcgi_send_timeout 300s;
}

0 个答案:

没有答案