htaccess 301 mod 重写匹配的 url 模式

发布于 2024-12-28 18:47:54 字数 399 浏览 2 评论 0原文

恐怕这超出了我的能力,经过大量研究和破坏后,我来寻求帮助。我有一个网址格式为:

example.com/7865/travel-photo/my-amazing-photo

我的客户现在决定在照片上添加“s”,因此网址变为:

example.com/7865/travel-photos/my-amazing-photo

一切都很好,仅此一点就不会成为问题,因为每个 URL 的数字“7865”都会发生变化,就像“我的令人惊叹的照片”确实如此。新 URL 的基本结构需要是:

example.com/'numbervariable'/travel-photos/'article namevariable'

所以我的问题是如何为此编写一个漂亮的 htaccess mod 重写规则?

This one's beyond my ability I'm afraid and after much research and breaking things I've come for help. I have a site with a URL in the format of:

example.com/7865/travel-photo/my-amazing-photo

My client has now decided he'd like to add an 's' onto photos so the URL has become:

example.com/7865/travel-photos/my-amazing-photo

All great and that alone wouldn't have been a problem only for the fact that the number '7865' changes for each URL just like the 'my-amazing-photo' does. The basic structure of the new URL needs to be:

example.com/'number variable'/travel-photos/'article name variable'

So my question how does write a beautiful htaccess mod rewrite rule for that?

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

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

发布评论

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

评论(1

微暖i 2025-01-04 18:47:55
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/travel-photos/(.*) $1/travel-photo/$2
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/travel-photos/(.*) $1/travel-photo/$2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文