301 Moved Permanently

Status

301 Moved Permanently

What is a 301 Moved Permanently HTTP response?

A 301 Moved Permanently HTTP response status code is used for the permanent redirection of a resource.

For example, a resource that was previously at www.example.com/page.html has permanently moved to www.example.com/newpage.html.

If the move may only be for a shorter period of time and is likely to be changed or reversed, then alternatively a 302 Found status would usually be preferable.

What type of HTTP status is a 301?

A 301 is in the 3xx class of status codes which are redirection based.

Other status codes in the 3xx class include 300, 302, 303, 304, 305, 306, 307, and 308.

How to create a 301 redirect in .Htaccess

To create a simple 301 redirect in .htaccess you can use the following.

To redirect a single page you can use:

Redirect 301 /example/ https://www.example.com/destination/
Code language: HTTP (http)

To redirect an entire site via .htaccess you can use:

Redirect 301 / https://www.example.com/
Code language: HTTP (http)

Example 301 Response Header

HTTP/1.1 301 Moved Permanently Location: https://www.destinationwebsite.com
Code language: HTTP (http)
<!DOCTYPE html> <html> <head> <title>301 Moved Permanently</title></head> <body> <h1>301</h1> <h2>Moved Permanently</h2> <p>The document has been permanently moved.</p> </body></html>
Code language: HTML, XML (xml)
An initial 301 redirect, followed by multiple 200 OK responses
Expanded view of a 301 redirect response from a server, as shown in Chrome network tools

Is a 301 response good for SEO?

When used appropriately a 301 redirect can be fine for SEO purposes.

Generally speaking it is good for your site to respond with a 200 success code.

It is also a good idea to minimise the amount of 301 redirects users may encounter, such as when redirecting users from http://domain.com to https://www.example.com.

301 vs 302 which is better?

If a redirect is going to be temporary then a 302 is the appropriate redirect to use, otherwise a 301 should be used for a redirect in almost all normal circumstances.

Created: Last updated:

chevron-down