为什么这个 mod_rewrite 规则不起作用(通过 .htaccess 一个特定的 url 到另一个)

发布于 2024-09-24 08:12:20 字数 58 浏览 4 评论 0原文

RewriteRule ^/tag/term$ /tag/term-expanded-here [R]

RewriteRule ^/tag/term$ /tag/term-expanded-here [R]

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

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

发布评论

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

评论(1

奶气 2024-10-01 08:12:20

如果您在 .htaccess 文件中使用 mod_rewrite,您需要从模式中删除路径前缀:

在 .htaccess 文件中使用重写引擎时,每个目录的前缀(对于特定目录始终相同)会自动删除以进行模式匹配,并自动添加 em> 替换完成后。

对于文档根目录中的 .htaccess 文件,它是前导 /

RewriteRule ^tag/term$ /tag/term-expanded-here [R]

If you’re using mod_rewrite in a .htaccess file, you need to remove the path prefix from the pattern:

When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the pattern matching and automatically added after the substitution has been done.

In case of the .htaccess file in the document root directory it’s the leading /:

RewriteRule ^tag/term$ /tag/term-expanded-here [R]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文