gpt4 book ai didi

php - 如果变量等于某个字符串,则 htaccess 重写条件

转载 作者:行者123 更新时间:2023-12-04 05:29:27 25 4
gpt4 key购买 nike

我在 .htaccess 文件中使用 mod rewrite 将 URL 更改为更好的 URL,它将转换为:

http://domain.com?a=test&v=page&id=3


http://domain.com/test/page/3

使用这个条件
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?a=$1&v=$2&id=$3 [L]

如果 $1 == cart 和 $2 == home,我想做一些不同的事情

这是使用 php if 的想法的一些伪代码条件
if($1 == 'cart' && $2 == 'home'){
here I want to do a different rewrite rule
}else{
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?a=$1&v=$2&id=$3 [L]
}

关于我如何去做的任何想法?

最佳答案

2 重写规则,首先使用预定义的规则:

RewriteRule ^cart/home/([^/\.]+)?$            page2.php?id=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?a=$1&v=$2&id=$3 [L]

关于php - 如果变量等于某个字符串,则 htaccess 重写条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12802823/

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