我要重写
[mysite.com/vehicle/car/honda
至mysite.com/vehicles.php?type=car&brand=Honda
。
我已经写了这个。
RewriteRule ^vehicle/(.+)/(.+)$ vehicles.php?type=$1&brand=$2 [NC,L]
这很好。但是,您可以看到,这不会将honda
转换为Honda
。有人可以帮我吗?
除非您编写自己的模块以扩展有限的内部Apache函数,否则您不能这样做。
来源:https://httpd.apache.org/docs/trunk/rewrite/rewritemap.html#int
您的Web服务器应该如何知道.../car/hondacivic
应该变成...&brand=HondaCivic
(Pascal情况)?
可能的解决方法:
1)请确保您的初始链接为mysite.com/vehicle/car/Honda
(大写H),以使其变为...&brand=Honda
...
2)...或仅在您的php文件中分配<?php $brand = ucfirst($_GET['brand']); ?>
。
不确定除了美学之外,它对您有多重要(很确定,它完全不影响SEO。