我是 url 重写的初学者。
我有一个这样的网址
http://www.sitename.com/subpages/detail.php?id=21-0043-052&car_name=abc
我想将此网站重定向到
http://www.qualitextrading.com/vehicle-detail.php?id=21-0043-052&car_name=abc
请问我如何将其写入 .htaccess 文件
假设您已启用
mod_rewrite
:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.sitename.com$ [NC]
RewriteRule ^\/subpages\/detail\.php(*.?)$ http://www.qualitextrading.com/vehicle-detail.php$1 [R=301,L]
这将打开该区域的重写,然后检查 HTTP_HOST 是否正确,然后重写 URL 并传递查询字符串(
mod_rewrite
的默认行为自动传递查询字符串)。