简体   繁体   中英

Redirect old domain https to new domain https

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.

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.

// 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]

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