How do i redirect one subfolder in one domain to another subfolder in another domain preserving path

heres the situation i have the domain 1

http://domain-1.com/somefolder-1

sometimes the domain 1 have someinformation after the subfolder

http://domain-1.com/somefolder-1/PRESERVE-THIS-PATH

What i need is to send the domain-1/somefolder-1

to another domain

http://domain-2.com/anotherfolder-1/PRESERVE-THIS-PATH

preserving the path if present

Upvotes: 0

Views: 30

Answers (1)

anubhava
anubhava

Reputation: 785256

You can use this rule in site root .htaccess of domain-1:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain-1\.com$ [NC]
RewriteRule ^somefolder-1(/.*)?$ http://domain-2.com/anotherfolder-1$1 [L,NC,R=301,NE]

Upvotes: 2

Related Questions