Pupik
Pupik

Reputation: 401

Http redirect 302 with regex

I need to make 302 redirection but I'm not able to achieve it, regex is just beyond my comprehension :(

What I need to achieve:

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

Target URL: this.target.com/string1/string2/string3/?id=1&extra=5

I highlited problematic parts - all of them stay the same in all redirects so they can be hardcoded.

EDIT: I need to put it to htaccess

Anybody can help me with this?

Thank you so much in advance!

Upvotes: 1

Views: 316

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

Try :

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]

Upvotes: 1

Related Questions