mod_rewrite URL 之前的 N 个目录

发布于 2024-09-14 17:21:59 字数 343 浏览 4 评论 0原文

我想从格式如下的 URL 重定向用户:

http://blog.mysite.com/any/number/of/directories/<POSTNAME>.html

TO:

http://mysite.com/about/blog/entry/<POSTNAME>/

哪里是相同的连字符分隔的字符串,并且原始 URL 在文件名之前可以有任意数量的目录(其中没有一个目录被“传递”到新 URL) 。

是否可以创建读取此模式的 htaccess 规则?

非常感谢您的帮助! :)

I want to redirect users from a URL formatted like this:

http://blog.mysite.com/any/number/of/directories/<POSTNAME>.html

TO:

http://mysite.com/about/blog/entry/<POSTNAME>/

Where is the same hyphen-separated string, and, the original URL can have any number of directories before the filename (none of which are 'passed' to the new URL).

Is it possible to create a htaccess rule which reaads this pattern?

Many thanks for your help! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

謌踐踏愛綪 2024-09-21 17:21:59

我想你正在寻找这样的东西:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^blog
RewriteRule ([^/]+)\.html$ http://example.com/about/blog/entry/$1/ [R=301,L]

I think you're looking for something like this:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^blog
RewriteRule ([^/]+)\.html$ http://example.com/about/blog/entry/$1/ [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文