This redirect comes from deleting a web page. Instead of displaying error 404 – Page not found in the browser where the navigation on the website ends, it is better from SEO perspective to redirect your web page via header 301.
During this redirect the web page will be redirected to a destination web page. Via redirect (HTTP 301) you can direct the visitor to a completely different URL than he entered. It is mostly used during web migration to a different domain or to keep a specific URL working for a time.
Redirect via .htaccess
a) redirect domain with www to a domain without www
This redirect is used to simplify displayed URL in the address line in the browser. If you do not want to have “www” displayed on your website, you can only show “yourdomain.tld”:
RewriteEngine On RewriteCond %{HTTP_HOST} ^www.yourdomain.tld [NC] RewriteRule ^(.*)$ http://yourdomain.tld/$1 [L,R=301]
b) redirect domain without www to a domain with www
An opposite example to the prior – if you want to display “www” in front of your domain in the address line. www.yourdomain.tld will be displayed:
RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain.tld [NC] RewriteRule ^(.*)$ http://www.yourdomain.tld/$1 [L,R=301]
c) permanent 301 redirect
You can use permanent redirect on a subdomain of your website to a different address – Google does not penalise this type of redirecting in the search results positions and for you it is not necessary to display “404 – page not found” to your visitor. Prefix http or https is very important in front of the destination domain. You can use this redirect even instead of Simple redirect if you have a hosting. Code is the following:
Redirect 301 / http://newdomain.tld
d) temporary 302 redirect
You can use it in a case of a maintenance on the web page/website. Prefix http or https is important in front of the destination domain. Code is the following:
Redirect 302 / http://new-domain.tld
Redirect via PHP
Not as much used type of redirect, but still possible to use to redirect your website if you are interested.
<?php header("Location: novadomena.sk", true, 301); exit(); ?>
Redirect via HTML
Mostly used in the past due to its simple and clear distinction in the code. It is also used to inform your visitor about certain information that you wish to display.
<!DOCTYPE html> <html> <head> <title>Redirect</title> <meta http-equiv="refresh" content="3;url=http://www.yourdomain.tld"> </head> <body> You will be redirected in 3 seconds. </body> </html>
(INFO: Attribute “content” determines the number of seconds before the redirect is initiated)
There exist other possible ways of redirecting (e.g. .asp redirect, javascript etc.) that didn’t make it into the guide. If you wish to inquire an information about other forms of redirects you can contact our customer care at: helpdesk@active24.eu.