Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.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
Regex 带正则表达式的Http重定向302_Regex_.htaccess_Http_Redirect_Http Status Code 302 - Fatal编程技术网

Regex 带正则表达式的Http重定向302

Regex 带正则表达式的Http重定向302,regex,.htaccess,http,redirect,http-status-code-302,Regex,.htaccess,Http,Redirect,Http Status Code 302,我需要进行302重定向,但我无法实现,正则表达式超出了我的理解:( 我需要达到的目标是: 原始URL:www.Original.com/out/string1/string2/string3/?id=1 目标URL:此目标.com/string1/string2/string3/?id=1&extra=5 我强调了有问题的部分——所有这些部分在所有重定向中都保持不变,因此可以硬编码 EDIT: I need to put it to htaccess 有人能帮我吗 非常感谢您!请尝试: Rew

我需要进行302重定向,但我无法实现,正则表达式超出了我的理解:(

我需要达到的目标是:

原始URL:www.Original.com/out/string1/string2/string3/?id=1

目标URL:目标.com/string1/string2/string3/?id=1&extra=5

我强调了有问题的部分——所有这些部分在所有重定向中都保持不变,因此可以硬编码

EDIT: I need to put it to htaccess
有人能帮我吗

非常感谢您!请尝试:

RewriteEngine on

RewriteCond %{THE_REQUEST} /out/([^/]+)/([^/]+)/([^/]+)/\?id=([0-9]+) [NC]
RewriteRule ^ http://this.target.com/%1/%2/%3/?id=%4&extra=5 [NE,L,R=302]

它可以工作,只是不会将目标网站url更改为this.target.com,而且您的硬编码id=1可能会有所不同。您可以将其添加到您的代码中吗?非常感谢!@Pupik我根据您的评论编辑了我的答案。请重新加载页面以查看它。