Rewrite escaped hashtag # #

2019-09-07 02:03发布

I recently noticed some incoming 404 error hits from URLs with their hashtag escaped.

Correct URL structure: http://example.org/#!/thepage or /index.html#!/thepage

Escaped/ Incorrect URL: http://example.org/%23!/thepage

I tried the following .htaccess rule with little success:

RewriteEngine on
RewriteRule ^%23!/(.*)$ /index.html#!/$1 [NE]

1条回答
姐就是有狂的资本
2楼-- · 2019-09-07 02:13

Thanks to this answer which pointed me into the right direction: https://webmasters.stackexchange.com/a/76059

Here is the rule that worked for me

RewriteRule ^\x23!/(.*)$ http://www.example.org/index.html#!/$1 [L,R=301,NE]

When using \x it will match escaped characters starting with %

查看更多
登录 后发表回答