简体   繁体   中英

.htaccess 301 redirect doamin A to domain B subfolder?

can someone help me how can I 301 redirect all pages of my old "siteA" to new "siteB/X"? (X is my sub folder)

question 2: If you want to redirect for example 50 websites' root to this "siteB/x", is it possible with one .htaccess file? what should I write in.htaccess file? (all those 50 websites are in same host and they pointed to a same single folder witch my .htaccess file is located there)

Thanks

I'm new to this and tried several methods but I couldn't find a solution yet. Please help

Currently I added following code in "siteB" root directory for redirect it to "siteB/x"

RewriteEngine on
RewriteCond %{HTTP_HOST} ^siteB\.com$
RewriteRule (.*) http://www.siteB.com/$1 [R=301,L]
RewriteRule ^$ fa [L]
RedirectMatch 301 ^/index\.php$ /X/index.php

and it working fine. But my problem is with siteA redirection. I used following code in siteA root dirctory and it redirecting siteA to siteB/x for main domain (but other links not working and they send error).

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*)$ http://www.siteB.com/$1 [R=301,L]    
    RewriteRule ^$ X [L]
    </IfModule>

I mean for example, currently, if I enter www.siteA.com in browser it will redirect it to www.siteB.com/x with no problem. But if I enter www.siteA.com/articles it will redirect to www.siteB.com/articles which is incorrent. ( I need to redirect to www.siteB.com/X/articles ) I hope you understanding what I mean

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