mod_rewrite 为 302 空白查询字符串
我目前正在处理:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 .htaccess 文件中使用 mod_rewrite 时,在测试模式之前将从请求的 URL 路径中删除基本路径。这意味着
/somepath
(或者更确切地说/somepath/
,因为您实际上位于/somepath/
中)被删除,以便剩余的路径是空的。所以: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: