问题
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:
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 %
来源:https://stackoverflow.com/questions/31714942/rewrite-escaped-hashtag-23