skip to Main Content

I did some redirects 301 from my old domain to a new domain on new host. But I checked that HTTPS version of older homepage site is still working and not redirecting to the new domain, but the links on old home page are redirecting to new domain links. How can I redirect the HTTPS version of my old domain to HTTPS version of my new domain? Below is part of my .htaccess

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{THE_REQUEST} /store/catalogsearch/result/index/ [NC]
RewriteRule ^ https://www.newdomain.com/? [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*(default|index).(html|php|htm) HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index).(html|php|htm)$ http://www.newdomain.com/$1 [R=301,NC]
RewriteRule ^store/?$ http://www.newdomain.com [L,NC,R=301]
RewriteRule ^store/folder/?$ http://www.newdomain.com/otherfolder/another-folder/ [L,NC,R=301]
RewriteRule ^store/folder1/folder2/?$ http://www.newdomain.com/folder-3/folder-4 [L,NC,R=301]

RewriteCond %{HTTP_HOST} ^(www.)?olddomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,NE,L]

Thanks in advance for your help.

2

Answers


  1. In the htaccess file you have to put just condition and rule for do your job.

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www.olddomain.com$
        RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
    </IfModule>
    

    In your code you wrote the ^ sign before the new domain name that was incorrect.

    Login or Signup to reply.
  2. // Try this ..

     <IfModule mod_rewrite.c>
      RewriteEngine On
      Redirect 301 / http://newdomain.com/
     </IfModule>
    
    OR
    
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^(www.)?http://olddomain.com$
      RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,QSA,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search