我想重定向以下网址结构:
/vehicle_details.php?veh_id=918
要:
http://www.example.co.uk/my/url
当veh_id
是任何东西时,我需要它,所以它会重定向所有。
答案 0 :(得分:0)
感谢@naomi的想法。
由于vehicle_details.php
是一个非常旧的文件,我将简单地创建一个新文件:
<?php
// old website redirects
header("Location: http://www.example.com/my/url/");
exit;
?>
答案 1 :(得分:0)
通过httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放在.htaccess
目录下的DOCUMENT_ROOT
中:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+vehicle_details\.php\?veh_id=[^\s]+ [NC]
RewriteRule ^ http://www.example.co.uk/my/url? [R=302,L]
验证一切正常后,将R=302
替换为R=301
。在测试mod_rewrite规则时,请避免使用R=301
(永久重定向)。