开发者

How to include a dash(#) in a htaccess rewrite rule?

开发者 https://www.devze.com 2022-12-21 17:56 出处:网络
As you know the dash introduces a comment how can I make this valid? Options +FollowSymlinks RewriteEngine on

As you know the dash introduces a comment

how can I make this valid?

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)开发者_如何学运维\.php$ /#$1 [R=301,NC]


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消