我是新手,我需要删除我的网址中出现的所有*.html扩展名,例如http://mywebsite.com/events.html/beauty-must-haves.html
我已经尝试了很多解决方案来解决这个问题,但是不能解决这个问题,有人能帮我解决这个问题吗?这些都不是硬编码的页面,它在运行时生成以下链接并不能帮助修复它。
how to serve html files in nginx without showing the extension in this alias setup
我需要它是搜索引擎友好的,例如http://mywebsite.com/events/beauty-must-haves
提前谢谢。
发布于 2017-08-21 14:41:36
下面的代码得到了我想要的结果,但是它没有删除URL中的.html扩展名,它只删除了结尾的扩展名:
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
rewrite ^/(.*)/$ /$1 permanent;
try_files $uri/index.html $uri.html $uri/ $uri =404;有什么要帮忙的吗请...?
发布于 2017-08-22 16:12:30
下面的代码用于隐藏URL中间的扩展名,但它重定向了两次:
rewrite ^(.+)\.html(/.*)?$ $1$2 permanent;
rewrite ^/(.*)/$ /$1 permanent;
try_files $uri/index.html $uri.html $uri/ $uri =404;我要求它在单个跨度内。有吗?缉毒局?
https://stackoverflow.com/questions/45782064
复制相似问题