A 301 Redirect enables you perform certain tasks including:
- Redirect the old URL of a web page to the new one
- Redirect website pages from an old domain to a new one
- Force all HTTP requests to HTTPS
- Consolidate duplicate pages that compete for the same keywords into one page
- Redirect a deleted page to another relevant page or your homepage
301 redirects on our shared hosting are performed using Apache's mod_rewrite module. You can enable them by editing (or creating) the following in your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
You may then proceed to add rewrite rules below "RewriteEngine On." The rules you add will depend on what exactly you want to redirect.
Common Examples
Redirecting a Single URL
Redirect 301 /old-page/ https://www.yourdomain.com/new-page/
Redirecting a Single Folder
RewriteRule ^/?blog/(.\*)$ /news/$1 [R,L]
Redirecting WWW to Non-WWW URLs with a 301 .htaccess Redirect
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule (.*) https://yourdomain.com/$1 [L,R=301]
More examples can be found in our "Apache mod_rewrite and examples" article.