如何在 htaccess 重写规则中包含破折号(#)?
如您所知,破折号引入了一条评论,
我怎样才能使其有效?
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.php$ /#$1 [R=301,NC]
As you know the dash introduces a comment
how can I make this valid?
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.php$ /#$1 [R=301,NC]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用NE标志:
顺便说一句:
#
只是 注释 如果在行首使用:Use the NE flag:
By the way: The
#
is only the start of a comment if used at the start of a line:apache 无法管理 # 之后的数据。甚至 facebook 也通过 javascript 处理 # 之后的数据重定向。
如果我错了,请有人纠正我,几年前这个问题让我发疯。
You can't manager data after # by apache. Even facebook handles redirection for data after # by javascript.
If I'm wrong, please someone correct me, some years ago this problem drives me crazy.
将
#
替换为\%23
,这样就可以解决问题,或者使用[NE]/noescape
标志。Replace the
#
with\%23
, and that should do the trick, or use the[NE]/noescape
flag.