我有NGINX服务器,我需要所有链接http://some/url重定向到http://some/url.html
这三个条件:request_uri不为空,最后没有斜杠,URL不以“.html”结尾
我试过这个:
server {
...
rewrite ^/(.+[^/])(?!.*\.html)$ $1.html permanent;
}
但它不起作用。
谢谢。
试试这样吧
server {
server_name some;
...
location /url {
try_files $uri $uri.html =404;
}
...
}