gpt4 book ai didi

apache - 使用参数重定向 URL

转载 作者:行者123 更新时间:2023-12-04 16:33:33 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





301 redirect .htaccess

(3 个回答)


去年关闭。




我想重定向网址:

prolist.php?id=1297&lang=en 
对此:
details.php?id=1297
但是 id 不想重定向在 URL 末尾没有“lang=en”参数的其他 URL。

最佳答案

因此,您希望为重定向规则实现一个条件,该条件与查询字符串的精确模式匹配:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(\d+)&lang=en$
RewriteRule ^/?prolist\.php$ /details.php?id=%1 [QSD,R=301]
也许你还想实现一个内部重写规则:
RewriteEngine on

RewriteCond %{QUERY_STRING} ^id=(\d+)&lang=en$
RewriteRule ^/?prolist\.php$ /details.php?id=%1 [QSD,L,R=301]

RewriteCond %{QUERY_STRING} ^id=(\d+)$
RewriteRule ^/?details\.php$ /prolist.php?id=%1&lang=en [L]

关于apache - 使用参数重定向 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63901447/

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