我正在尝试使 .htaccess 重写规则映射 4 个不同的获取变量并排除一个字符串。字符串是不变的,即。永远保持不变。
当前网址是:
/car.php?make=bmw&model=z4&year=2006&color=black_metallic
应该是这样的:
car/bmw-z4-2006-black_metallic-for-sale
这是我到目前为止所做的
RewriteRule ^car/^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ car.php?make=$1&model=$2&year=$3&color=$4
现在我需要忽略漂亮 url 末尾的字符串 -for-sale。
非常感谢任何帮助!
最佳答案
试试这个
RewriteRule ^car/([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)/?$ car.php?make=$1&model=$2&year=$3&color=$4 [QSA,NC,L]
关于apache - .htaccess 重写规则忽略字符串,url 中的多个 GET 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29711863/