skip to Main Content

slightly confused about all of these redirect codes. So I have a website that has been live on

https://domainA.com/subfolder

I have recently duplicated the site, but need to move it to a new domain

https://domainB.com/subfolder

However, if people still visit the first domain, I need them to be redirected to the new domain. However, I do not want to lose the SEO I have on the original domain.

I have seen that I could do a 301 or 303 redirect, although not sure what my best option is? At the moment, within .htaccess I have added

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^https://domainA.com/subfolder/[NC,OR]
RewriteCond %{HTTP_HOST} ^https://domainA.com/subfolder/ [NC]
RewriteRule ^(.*)$ https://domainB.com/subfolder/$1 [L,R=301,NC]
</IfModule>

This does not seem to do anything at the moment though.

Am I missing something?

Thanks

2

Answers


  1. I think you’d better work on Apache configuration file /etc/apache2/sites-available/your-site.conf

    Login or Signup to reply.
  2. Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/subfolder(.*)$
    RewriteRule ^(.*) https://domainB.com%{REQUEST_URI} [R=301,NC]
    

    This should work please report feedback

    Regarding your question. Google advices 301 redirects so I think that is better keep it that way


    Different subfoder

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/subfolder(.*)$
    RewriteRule ^(.*) https://domainB.com/DifferentSubFodler [R=301,NC]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search