regex - 使用正则表达式的 Http 重定向 302

标签 regex .htaccess http redirect http-status-code-302

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

我需要达到的目标:

原始网址:www.original.com/out/string1/string2/string3/?id=1

目标网址:this.target.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]

关于regex - 使用正则表达式的 Http 重定向 302,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35653658/

相关文章:

.htaccess - htaccess 重写规则不起作用

python asyncio aiohttp 超时

.htaccess 如果 URL 的子域删除 https

正则表达式——将一列拆分为多列,在 R 中没有明确的分隔符

javascript - 需要使用正则表达式将大学类(class)代码拆分为前缀和后缀

apache - 将所有请求重定向到index.php except/files 子目录

.htaccess - 如何通过htaccess保护店铺?

javascript - 在 javascript 中使用正则表达式匹配并返回 [] 中包含的所有字符串

java - 用于组合多个序列的正则表达式

java - http get 返回 403