1

I have a client that has several files whose name is (for example) car.php, car_edit.php, car_review.php. These each come with query strings - so car.php?id=1234 or car_review.php?id=321. They would like the file names to be truck*.php rather than car*.php.

I'm hoping there's a way using htaccess to convert the url string to be truck*.php and use the current car*.php files. Also if possible I'd like to forward any page asking for car*.php to truck*.php.

I've done quite a bit of searching and haven't found an answer to doing this particular thing. Does anyone know how I might do this? Thanks.

4

2 回答 2

1

你需要重写规则。尝试类似:

RewriteRule ^truck(.*).php$ /car.php?id=$1 [NC,L]

注意:这是未经测试的,因此可能需要调整。

于 2013-11-07T19:04:25.967 回答
0
  RewriteEngine On
  RewriteRule  ^truck(.*)\.php$   /car$1.php  [NC]

应该这样做。它应该自动将任何 URL 查询字符串(如 id=xxx)传输到 car*.php 重写的 URL。

于 2013-11-07T19:08:20.863 回答