我想获取此网址:
example.com/scooter-details/1/vespa-sprint
但是我得到的网址是:
example.com/scooter-details.php?scooter_id=1&scooter_brand=vespasprint&scooter_model=
scooter_model“sprint”位于scooter_brand查询中,通常必须是scooter_brand=vespa&scooter_model=sprint。希望你能帮我解决这个问题
htaccess 代码Options +FollowSymLinks -MultiViews
RewriteEngine On
# SEO FRIENDLY URL
# Redirect "/scooter-details.php?service_id=<num>" to "/scooter-details/<num>"
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^scooter_id=(\d+)&scooter_brand=([^/.]+)&scooter_model=([^/.]+)$
RewriteRule ^(scooter-details)\.php$ /$1/%1/$2%2-$3%3? [QSD,L,R=301,N]
# Rewrite "/scooter-details/<num>" back to "scooter-details.php?service_id=<num>"
RewriteRule ^(scooter-details)/(\d+)/([^/]+)$ $1.php?scooter_id=$2&scooter_brand=$3&scooter_model=$4 [L] Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
如果您要捕获查询字符串的元素(即已经 URL 编码)并使用它们来构建 URL 路径。否则,您最终将得到结果 URL 路径的双重 URL 编码部分 - 这就是它的样子。
%2520是双重 URL 编码的空格。 IE。您正在捕获的查询字符串中似乎有%20(即空格)。但是,您发布的规则似乎与给出的示例 URL 无关?