301

Moved Permanently

3xx Redirection The URL of the requested resource has been changed permanently

Code Examples

Here are examples of how to test HTTP 301 responses in different programming languages:

Select options below to see how to use advanced features in your code:

Request:
curl https://free.mockerapi.com/301
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
fetch('https://free.mockerapi.com/301')
  .then(response => {
    console.log('Status:', response.status); // 301
    return response.json();
  })
  .then(data => {
    console.log('Success:', data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
import requests

response = requests.get('https://free.mockerapi.com/301')

print(f'Status Code: {response.status_code}')  # 301
print(f'Response: {response.json()}')
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
require 'net/http'
require 'json'

uri = URI('https://free.mockerapi.com/301')
response = Net::HTTP.get_response(uri)

puts "Status Code: #{response.code}"  # 301
puts "Response: #{JSON.parse(response.body)}"
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    resp, err := http.Get("https://free.mockerapi.com/301")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Printf("Status Code: %d\n", resp.StatusCode)  // 301

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }

    fmt.Printf("Response: %s\n", body)
}
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
import java.net.http.*;
import java.net.URI;

public class HttpStatusTest {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://free.mockerapi.com/301"))
            .GET()
            .build();

        HttpResponse response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println("Status Code: " + response.statusCode());  // 301
        System.out.println("Response: " + response.body());
    }
}
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}
Request:
const https = require('https');

https.get('https://free.mockerapi.com/301', (res) => {
  console.log('Status Code:', res.statusCode);  // 301

  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    console.log('Response:', JSON.parse(data));
  });
}).on('error', (err) => {
  console.error('Error:', err.message);
});
Response Body:
{
  "success": true,
  "status": 301,
  "statusText": "Moved Permanently - The URL of the requested resource has been changed permanently",
  "timestamp": "2025-10-08T10:30:45.123Z",
  "request": {
    "method": "GET",
    "url": "/301",
    "fullUrl": "https://free.mockerapi.com/301"
  }
}

What is HTTP 301 Moved Permanently?

HTTP 301 Moved Permanently indicates that the requested resource has been permanently moved to a new URL. This status code tells clients and search engines that the resource should be requested from the new location in all future requests.

The server should include a Location header in the response indicating the new permanent URI. Browsers and clients typically automatically redirect to the new location, and search engines transfer the SEO value from the old URL to the new one.

When Does This Happen?

A 301 Moved Permanently response is returned when:

  • A page has permanently moved to a new URL (e.g., site restructuring)
  • Migrating from HTTP to HTTPS for a website
  • Consolidating multiple pages into a single page
  • Changing domain names while preserving SEO rankings
  • Implementing URL canonicalization (e.g., www to non-www)

Try It Live

Click the button below to make a live request and see the 301 Moved Permanently response

Common Use Cases

๐Ÿ”„ Redirect Testing

Test how your application handles permanent redirects and updates cached URLs appropriately.

๐Ÿ” HTTPS Migration

Mock and test HTTPS migration scenarios where HTTP URLs permanently redirect to HTTPS.

๐Ÿ” SEO Testing

Test SEO tools and crawlers to ensure they properly handle permanent redirects and URL changes.

๐ŸŒ Domain Migration

Test client behavior during domain migrations where old URLs redirect to new domains.

๐Ÿ“ฑ Link Preservation

Verify that applications properly follow redirects to maintain functionality when URLs change.

๐Ÿงช Client Behavior

Test how different HTTP clients handle Location headers and automatic redirect following.

Related Redirection Status Codes