我正在使用.htaccess文件来重定向" http://www.domain.com/cars/cars.php?cars_item=231"到" http://www.domain.com/cars/231/porsche"
所以基本上我重定向' cars.php?cars_item = 231'到' $ id / $ title'
.htaccess文件包含:
#Start
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Redirect cars.php?cars_item=231 to cars/231/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+cars/cars\.php\?cars_item=([^&\s]+) [NC]
RewriteRule ^ /cars/%1 [R=302,L]
# Internally forward cars/231/ to cars.php?cars_item=231
RewriteRule ^cars/([0-9]+) /cars/cars.php?cars_item=$1 [NC,L,QSA]
#end
然后我使用以下href:
&#34; http://domain.com/index.php&#34; = echo <a href=\"cars/$id/$title_new\">porsche</a>;
和&#34; http://www.domain.com/cars/cars.php&#34;我正在使用$ _GET [&#39; cars_item&#39;];
我的问题是:我怎么能从网址中删除$ id?我希望得到以下网址 - &#34; http://www.domain.com/cars/porsche&#34; ...所以基本上我想更新.htaccess并重定向&#34; http://www.domain.com/cars/cars.php?cars_item=231&#34;到&#34; http://www.domain.com/cars/porsche&#34;
这是因为url中的$ id特别为索引创建了一些问题。 Google一直在抓取&#34; http://www.domain.com/cars/ $ id /&#34;因为$ id不是文件夹而是db行,因此我想从URL中删除$ id。
我将一如既往地感谢您的帮助。