尝试 mod_rewrite 目录
我正在尝试使用 httpd 进行 mod_rewrite
我希望源:
www.foo.bar.com/abc/
转到目标:
www.foo.bar.com/def/
所以我已经到达:
RewriteRule ^abc/([^/\.]+).$ def/$1 [L]
但我不仅希望它用于该页面,我还希望该 url 之后的所有后续页面也能重写。
示例 www.foo.bar.com/abc/blahblahblah1.html
转到 www.foo.bar.com/def/blahblahblah1.html
问题是我不我认为这是对的,因为它似乎不起作用。
Im trying to mod_rewrite using httpd
I want Source:
www.foo.bar.com/abc/
to go to Destination:
www.foo.bar.com/def/
So I've arrived at:
RewriteRule ^abc/([^/\.]+).$ def/$1 [L]
But i don't only want it for that one page, i want all subsequent pages following the url to rewrite also.
Example www.foo.bar.com/abc/blahblahblah1.html
to goto www.foo.bar.com/def/blahblahblah1.html
The problem is I don't think this is right, because it doesn't seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
稍微简化了一下,因为我不确定为什么你要在任何给定的“/”或“.”处停止重写。 - 可能会导致一些奇怪的行为。
这是假设您在
.htaccess
(在文档根目录中)而不是httpd-vhosts.conf
中执行重写(在两者之间的路径)。Simplified it a little as I'm not sure why you're stopping the rewrite at any given '/' or '.' - could lead to some odd behaviour.
This is assuming you're performing the rewrite in
.htaccess
(in the document root) rather than, say,httpd-vhosts.conf
(there may be slight differences in the paths between the two).这假设
.htaccess
位于您的 DOCROOT 中。始终指定一个基础——即 / 代表文档根目录。不要包含每个目录的前导 /(在.htaccess
中)。This assumes that the
.htaccess
is in your DOCROOT. Always specify a base -- which is / for your document root. Do not include the leading / for Per Directory (in.htaccess
).