如何在Rewrite_Map中允许特殊字符?

问题描述 投票:0回答:1

这是我正在使用的配置

RewriteEngine on
RewriteMap shortlinks txt:/var/www/html/s.overhash.net/public_html/shortlinks.txt
RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L]

我的txt文档看起来像这样:

9H40o https://osyrisrblx.github.io/playground/#code/HYUw7gBAggTjCGBPAPMArgWwEYhgPgAoBKAOhhABM0BjEAggB3IDcAaCatOEYAFyIC8eJiGYBqAZ258iQA

但是,到我的网站(http://s.overhash.net/9H40o)时,它用%23替换了#,使URL变为:

https://osyrisrblx.github.io/playground/%23code/HYUw7gBAggTjCGBPAPMArgWwEYhgPgAoBKAOhhABM0BjEAggB3IDcAaCatOEYAFyIC8eJiGYBqAZ258iQA

(无效)

我将如何确保保留#

apache apache2 url-shortener
1个回答
0
投票

这不是重写映射的问题,这是重写规则的工作方式。默认情况下,特殊字符将被转义。

如果您不希望发生这种情况,请在重写器中使用NE标志:

RewriteRule ^/(.+)$ ${shortlinks:$1} [NE,R=temp,L]

关于https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_ne的更多详细信息

© www.soinside.com 2019 - 2024. All rights reserved.