比较来自世界各地的卖家的域名和 IT 服务价格

301 重定向用户链接

我有几千这样的链接

/Gallery?cmd=viewCarGallery&carID=3747&pgID=1

现在我想用它重定向 .htaccess 在另一个网站上通过引用他人。 每个链接都将重定向到其目标链接。 我试过这样的

Redirect 301 /Gallery?cmd=viewCarGallery&carID=3747&pgID=1 [url=http://example.com/gallery/fcar_gallery]http://example.com/gallery/fcar_gallery[/url]

但不起作用。 我打开了 mod_rewrite 在我的服务器上,其他重定向工作正常。
已邀请:

冰洋

赞同来自:

查询字符串不是指令中符合性的一部分 Redirect, 要重定向查询字符串,您需要使用mod-opetwriting如下:

选项 1

RewriteEngine on

RewriteCond %{THE_REQUEST} /Gallery\?cmd=viewCarGallery&carID=3747&pgID=1 [NC]
RewriteRule ^ [url=http://example.com/gallery/fcar_gallery?]http://example.com/gallery/fcar_gallery?[/url] [NC,L,R]

选项 2

RewriteEngine on

RewriteCond %{QUERY_STRING} ^cmd=viewCarGallery&carID=3747&pgID=1 [NC]
RewriteRule ^ [url=http://example.com/gallery/fcar_gallery?]http://example.com/gallery/fcar_gallery?[/url] [NC,L,R]

我们使用一个空的问号

?

在目标URL的末尾放弃旧查询行,否则这些查询行被添加到默认的目标URL。

改变

R.



R = 301

如果要永久性重定向。

[核实 apache2 和 2.4]

要回复问题请先登录注册