Types of Redirects

  • 301, "Moved Permanently"—recommended for SEO
  • 302, "Found" or "Moved Temporarily"

Pages redirection

Redirect 301 /pageA.html http://www.site.com/pageB.htm
RedirectPermanent /pageA.html http://www.site.com/pageB.html

Domain redirection

HTTP to HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

All traffic

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Only 1 domain

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Subfolder to main domain

RewriteEngine on
RewriteBase /
RewriteRule ^subfolder/(.*)$ /$1 [R=302,NC,L]


Change R=302 to R=301 after you've validated the changes. This is useful when enabling the Multistore option in Prestashop, and it is needed to hide the other stores virtual subdomains.

Others

RewriteCond %{HTTP_HOST} ^old-domain\.fr [NC]
RewriteRule ^/?(.*) http://www.new-domain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^www.old-domain\.fr [NC]
RewriteRule ^/?(.*) http://www.new-domain.com/$1 [L,R=301]

Language redirections

Ideally, temporary redirections for disabled languages; and permanent redirections for a languge which was deleted.

To the main page:

RewriteEngine on
RewriteRule ^fr/(.*)$ / [R=302,L]
RewriteRule ^en/(.*)$ / [R=302,L]
RewriteRule ^nl/(.*)$ / [R=302,L]
RewriteRule ^de/(.*)$ / [R=302,L]


Keep the link:

RewriteEngine on
RewriteRule ^fr/(.*)$ /$1 [R=302,L]
RewriteRule ^en/(.*)$ /$1 [R=302,L]
RewriteRule ^nl/(.*)$ /$1 [R=302,L]
RewriteRule ^de/(.*)$ /$1 [R=302,L]