如何在 htaccess 重写规则中包含破折号(#)?

发布于 2024-08-23 05:50:47 字数 149 浏览 2 评论 0原文

如您所知,破折号引入了一条评论,

我怎样才能使其有效?

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 技术交流群。

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

发布评论

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

评论(3

鸢与 2024-08-30 05:50:47

使用NE标志

RewriteRule ^(.+)\.php$ /#$1 [R=301,NE]

顺便说一句: # 只是 注释 如果在行首使用:

以井号字符“#”开头的行被视为注释,并会被忽略。配置指令后面的一行中不能包含注释。

Use the NE flag:

RewriteRule ^(.+)\.php$ /#$1 [R=301,NE]

By the way: The # is only the start of a comment if used at the start of a line:

Lines that begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on a line after a configuration directive.

北座城市 2024-08-30 05:50:47

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.

被你宠の有点坏 2024-08-30 05:50:47

# 替换为 \%23,这样就可以解决问题,或者使用 [NE]/noescape 标志。

Replace the # with \%23, and that should do the trick, or use the [NE]/noescape flag.

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