mod_rewrite 为 302 空白查询字符串

发布于 2024-09-27 11:00:49 字数 198 浏览 1 评论 0原文

我目前正在处理:

RewriteEngine On
RewriteBase /somepath

RewriteRule ^/$ home [R]

我希望将 GET /somepath 请求通过 302 重定向到 /somepath/home。我在这里缺少什么?

I'm currently working with:

RewriteEngine On
RewriteBase /somepath

RewriteRule ^/$ home [R]

I'd like to have requests of GET /somepath to redirect via 302 to /somepath/home. What am I missing here?

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

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

发布评论

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

评论(1

淡紫姑娘! 2024-10-04 11:00:49

在 .htaccess 文件中使用 mod_rewrite 时,在测试模式之前将从请求的 URL 路径中删除基本路径。这意味着 /somepath (或者更确切地说 /somepath/,因为您实际上位于 /somepath/ 中)被删除,以便剩余的路径是空的。所以:

RewriteRule ^$ home [R]

When using mod_rewrite in an .htaccess file, the base path is removed from the requested URL path before testing the patterns. That means /somepath (or rather /somepath/, since you’re actually in /somepath/) is removed so that the remaining path is empty. So:

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