【发布时间】:2018-12-16 01:07:44
【问题描述】:
我使用 nginx 和 wordpress。有人黑了一个非常受欢迎的博客帐户,现在我试图在这个网站上生存。我想保护旧地址和永久链接。我进行了一项研究,但由于关于该主题的类似结果而无法找到。抱歉,如果这是重复的。
如何在我的网址后的固定链接后添加.html。我试过这个,但我在浏览器中得到 404。
location / {
try_files $uri $uri/ @htmlext;
}
location ~ \.html$ {
try_files $uri =404;
}
location @htmlext {
#rewrite ^(.*)$ $1.html last;
rewrite ^(.*)$ $1.html permanent;
}
谢谢
【问题讨论】:
-
您的问题不清楚。 “仅在浏览器中”是什么意思?是否要将请求
example.com/some/path/重写为example.com/some/path.html?或者将请求example.com/some/path.html重写为example.com/some/path/?您现在的网站上是否有静态 html 文件而不是 wordpress 核心? -
其实我解决了。我不必将“.html”添加到来自 nginx 的 url。 Wordpress 在自定义永久链接中处理它。不确定删除问题或留下问题有人可以搜索类似这样的问题。
标签: wordpress nginx url-rewriting