Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 仅重定向具有htaccess的搜索链接_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 仅重定向具有htaccess的搜索链接

.htaccess 仅重定向具有htaccess的搜索链接,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我只想将我的所有搜索查询重定向到另一个域帖子,如 domainA.com/?s=this+is+source+link+ domainA.com/?s=+此+为+源+链接+ domainA.com/?s=this+is+source+link+3 domainA.com/?s=this+is+source+link+4 将转到另一个域上的同一页 domainB.com/destination-page 我测试了正常的301重定向代码无法工作,请任何人帮助我如何执行此操作?您正在寻找: Rewr

我只想将我的所有搜索查询重定向到另一个域帖子,如

domainA.com/?s=this+is+source+link+
domainA.com/?s=+此+为+源+链接+
domainA.com/?s=this+is+source+link+3
domainA.com/?s=this+is+source+link+4

将转到另一个域上的同一页

domainB.com/destination-page
我测试了正常的301重定向代码无法工作,请任何人帮助我如何执行此操作?

您正在寻找:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^s=this\+is\+source\+link
RewriteRule ^$ http://domainb.com/destination-page? [R=301,L]
这将使用以“s=this+is+source+link”开头的查询字符串将任何对主页的访问重定向到您指定的页面。它应该放在域根目录下的.htaccess文件中

在评论中更新以下讨论

要重定向查询字符串开头带有
s=
且具有任意值的所有内容,请执行以下操作:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^s=
RewriteRule ^$ http://domainb.com/destination-page? [R=301,L]

如果你想匹配查询字符串内容,你需要使用RewriteCond。你能给我代码吗?不。请做研究。你好,谢谢你,你的代码重定向得很好,但有一个小问题,它在目标url中添加了“?s=这是源链接”,并给出了页面未发现错误,有什么想法吗?啊,是的,当然有。很抱歉。我更新了代码,以便在重定向之前删除查询字符串(在最后一行的重定向URL末尾添加问号)。我看你是新来的。欢迎:)请用我答案左上角的勾号表示您接受它,并给我一些声誉分数。谢谢好东西,很高兴听到。谢谢。如果您可能会得到包含多个参数的查询字符串,并且s不是第一个参数,那么它也可以更新为重定向查询字符串中任何包含s=的内容。再次感谢,它工作正常,您的代码节省了我的时间。