如何将每个博客的前缀都带有“ new-”使用htaccess
我想在每个博客URL slug中添加“新”。
例如,如果某人访问https://www.example.com/blog/post-one
它将重定向到https://www.example.com/blog/new-post - 一个
。
I want to add "new" to every blog URL slug.
For example, if someone visits https://www.example.com/blog/post-one
it will redirect to https://www.example.com/blog/new-post-one
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在root
.htaccess
文件的顶部,使用mod_rewrite尝试以下内容:假设
< post-title>
仅由字符az
组成,az
,0-9
,_
(underscore)和-
(杂种)(?!) new - )
- 这是否定的lookahead ,它断言< post-title>
尚未以new - 。否则,我们将获得无尽的重定向循环。
您无需重复
RewriteEngine
指令是否已经在文件中(以后)中发生。At the top of the root
.htaccess
file try the following using mod_rewrite:This assumes
<post-title>
consists of only the charactersa-z
,A-Z
,0-9
,_
(underscore) and-
(hyphen)(?!new-)
- this is a negative lookahead that asserts that the<post-title>
does not already start withnew-
. Otherwise we would get an endless redirect loop.You do not need to repeat the
RewriteEngine
directive if it already occurs (later) in the file.