Rewrite escaped hashtag # %23

一笑奈何 提交于 2019-12-13 07:40:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!