gpt4 book ai didi

regex - Apache Mod 重写 - 替换 : character with another

转载 作者:行者123 更新时间:2023-12-02 00:44:21 24 4
gpt4 key购买 nike

我正在尝试将其中包含“:”的所有 URL 重写为另一个字符。 http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words

例子:

http://example.com/some_interesting:info
http://example.com/some_interesting_info
http://example.com/some:interesting:info
http://example.com/some:interesting_info

都会指向这个文件

some_interesting_info

我该怎么做?

编辑:做了更多测试

这行得通

RewriteRule ^(.*)_(.*) $1$2 [L]
RewriteRule ^(.*)\_+(.*) $1$2 [L]

test_rewrite.html 转到testrewrite.html

这不是

RewriteRule ^(.*):(.*) $1$2 [L]
RewriteRule ^(.*)\:+(.*) $1$2 [L]

test:rewrite.html 给出 403

在消除中间字符方面。使用 xammp 1.7.1 测试

最佳答案

试试这些规则:

RewriteRule ^/([^:]*):([^:]*:.*) /$1_$2 [N]
RewriteRule ^/([^:]*):([^:]*)$ /$1_$2

关于regex - Apache Mod 重写 - 替换 : character with another,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1345314/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com