HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

301 Moved Permanently

Fault: Neither
TL;DR

All future requests should use the new URL provided in the Location header.

The resource has been permanently moved to a new URL.

What HTTP 301 Moved Permanently Means

The resource has been permanently moved to a new URL.

All future requests should use the new URL provided in the Location header.

Common Causes

How to Fix It (For Visitors)

How to Fix It (For Developers/Admins)

Returning a 301 Moved Permanently (Code Examples)

If you build APIs or web apps, here is how to send an HTTP 301 response and how to test for it:

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(301).json({ error: 'Moved Permanently' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Moved Permanently'), 301

PHP

<?php
http_response_code(301);
header('Content-Type: application/json');
echo json_encode(['error' => 'Moved Permanently']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 301 Moved Permanently

Frequently Asked Questions

What does HTTP 301 Moved Permanently mean?

All future requests should use the new URL provided in the Location header. In short: The resource has been permanently moved to a new URL.

How should I handle an HTTP 301 Moved Permanently response?

Update internal links to new URL. Use for permanent URL changes. Set Location header.

Official Specification

The 301 Moved Permanently status code is defined in RFC 7231 Section 6.4.2.

View the IANA HTTP Status Code Registry →