htaccess rewrite rule with escaped ampersand in $_GET fails

前端 未结 1 1203
我寻月下人不归
我寻月下人不归 2020-12-10 03:59

I am encountering a problem with a get parameter in conjunction with a htaccess rewrite rule. Below is the urlencode()\'ed link; the rewrite rule I use to redirect to index

相关标签:
1条回答
  • 2020-12-10 04:35

    Ah, okay. Interesting. It seems there is a special solution for keeping that ampersand specifically escaped. Use the [B] flag for Rewriterules.

    RewriteRule ^static/(.*)$ /index.php?static=$1 [L,B]
    

    This is supposed to urlencode special characters when interpolating the $1 placeholder. It only works with Apache 2.2 however I believe.

    Found a few references:

    • http://www.dracos.co.uk/code/apache-rewrite-problem/
    • mod_rewrite with question marks and ampersands (with PHP)
    • http://www.mediawiki.org/wiki/Manual:Short_URL/Ampersand_solution
    0 讨论(0)
提交回复
热议问题