gpt4 book ai didi

.htaccess 重写带问号的 URL "?"

转载 作者:行者123 更新时间:2023-12-02 21:41:51 26 4
gpt4 key购买 nike

我的目标是这个网址:

component/users/?view=registration

致:

registration.html

.htaccess 位于网站的 mysite 文件夹中。

我尝试过这个:

RewriteBase /mysite
RewriteRule ^component/users/?view=registration$ registration.html$ [R=301,L]

但是我不工作...

当我尝试这个时:

RewriteRule ^component/users/_view=registration$ registration.html$ [R=301,L]

效果非常好。

那么我该如何解决这个带有问号的问题。我已经读过那是 it is not a part of the URL (其附后)。我读过我必须使用像查询字符串这样的东西,但我并没有真正理解语法。

也许有人可以写出这个问题的解决方案?太棒了 =)

最佳答案

您需要使用%{QUERY_STRING}来捕获查询字符串数据:

RewriteCond %{QUERY_STRING} ^view=(.*)$
RewriteRule ^component/users/?$ %1.html? [R=301,L]

如果路径 component/users 匹配,上述规则/条件将采用查询字符串 View 的值并使用它来形成重定向。

关于.htaccess 重写带问号的 URL "?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18543194/

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