简体   繁体   中英

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM