我有一个非常有趣的行为。我想避免在我的网站上的 URL 中使用斜杠。我已将rewrite ^/(.*)/$ /$1 permanent;
规则放入我的服务器块中,因此
https://example.com/something/
,
https://example.com/something////
重定向到
https://example.com/something
;
并
https://example.com/
重定向到
https://example.com
但是https://example.com////
被重定向到... https://enjoygifts.ru////
(实际上没有重定向,它是 200 代码)。为什么?
这是我的服务器块:
服务器 { 听 443 ssl; ... ... ssl 指令 ... 根 /var/www/mysite.com; 索引 index.php; server_name mysite.com; 重写 ^/(.*)/$ /$1 永久; 地点 / { 最后重写 ^/.*$ /index.php; } 位置 ~ ^/index.php { try_files $uri =404; 包括/etc/nginx/fastcgi.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; } 位置 ~ ^/storage/app/uploads/public { try_files $uri 404; } ... ...很多类似的位置块 ... }