Nginx子文件夹重定向到带有斜杠的URL

时间:2019-02-19 14:49:51

标签: nginx

这是我的设置:

location ~ \.php$ {
    include fastcgi_params;
    include fastcgi.conf;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php-fpm.sock;
    fastcgi_param SCRIPT_FILENAME /var/www/html/example.com$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
}

if ($request_uri ~* "^(.*/)index\.html$") {
    return 301 $1;
}

location / {
    root   /var/www/html/example.com;
    index  index.php index.html index.htm;
}

当我转到网址https://example.com/subfolder时,浏览器会将我重定向到https://example.com/subfolder/,如果我尝试用rewrite ^/(.*)/$ /$1 permanent;删除尾部斜杠,则重定向太多。

是否可以删除子文件夹的斜杠?

0 个答案:

没有答案