gpt4 book ai didi

.htaccess 在 URL 中带有 `#`

转载 作者:行者123 更新时间:2023-12-01 12:53:14 26 4
gpt4 key购买 nike

我想在我的网站上将 /tagged/c# 映射到 /?tagged=c#。显然,# 不会被服务器看到,所以我将其 URL 编码为 %23。这是我正在使用的 .htaccess:

RewriteBase /
RewriteEngine On
RewriteRule ^tagged/(.*)$ /?tagged=$1 [NC]

如您所料,这有效,传递了 C# 的查询:

/?tagged=C%23

但是这些都没有,都给出了 C

的传递查询
/tagged/C%23
/tagged/C%23moretextthatgetslost

我假设 # 被解释为文字散列,因此在途中某处丢失了。

我需要做什么才能使这些第二种情况起作用?

最佳答案

原来我需要使用 [B]标志:

RewriteBase /
RewriteEngine On
RewriteRule ^tagged/(.*)$ /?tagged=$1 [NC,B]

解释文档:

With the B flag, it will instead map /C%2b%2b to /index.php?show=/C%2b%2b.

关于.htaccess 在 URL 中带有 `#`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10970436/

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