htaccess

301 Redirects are permanent redirections, so it redirects a certain URL to another one.

When we use them?

  • When the website url changes for the same content. For example http://www.website.tld/oldpage -> http://www.website.tld/newpage
  • When the main url of a website changes. For example http://www.oldwebsite.tld/page -> http://www.newwebsite.tld/page

Why we use them?

  • In order to keep the links that were already indexed by search engines.
  • To keep customers on your website when the url changes.

How to use them

301 redirects are added to the .htaccess file on an Apache server.

Redirect 301 [old page url] [new page url]

For pages:

Redirect 301 /oldpage.html https://www.url.tld/newpage.html
Redirect 301 /oldpage2.html https://www.url.tld/newpage2.html
Redirect 301 /oldpage3.html https://www.url.tld/newpage3.html

For an entire website:

Redirect 301 / https://www.newurl.tld