Link Web and COVID-19. Click here.

Common .htaccess redirect rules

Redirect non-www to www

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect http to https

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect old domain to a single page

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{http_host} ^olddomain.com
RewriteCond %{http_host} ^www.olddomain.com
RewriteRule (.*) https://www.newdomain.com/new-page/ [R=301,L]

Redirect old domain to new domain

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]

© Copyright Link Web Development Ltd. 2020 - 2021
Follow Us: