Skip to content

Halo博客的链接问题,链接末尾带斜杠会导致404 #5420

@GuGuGee

Description

@GuGuGee

Your current Halo version

2.13.0-rc.1

Describe this feature

开发者好!我是从Wordpress搬家到Halo的,之前在Wordpress里面,默认的链接都是类似aa.com/123/的,
image-20240229095845090
现在文章迁移到halo之后,链接变成了aa.com/123,由于之前在很多平台上都有留类似aa.com/123/这种末尾带/的链接,访客访问aa.com/123/会提示404,会给他们造成困扰,以为链接挂了。
我借助ChatGPT,在nginx配置文件里面添加了重写规则:

    rewrite ^/(.*)/$ /$1 permanent;

意图将以斜杠("/")结尾的请求重定向到没有斜杠的相同路径,目前来看可以解决一些问题。

不过担心是否会存在如果有些资源(例如CSS文件)的URL以斜杠结尾也重定向导致其他问题?

或者说是否有更好的解决方案?谢谢!

Additional information

No response

Metadata

Metadata

Assignees

Labels

area/coreIssues or PRs related to the Halo Corekind/improvementCategorizes issue or PR as related to a improvement.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions