HTTP 308 Response Status Code Guide: What is it, Usage, Methods

May 21 2024 by Oskay Günaçar

What is HTTP 308 Status Code?

The HTTP 308 status code is a permanent redirect response status code. It indicates that the requested resource has been permanently moved to a new URL provided by the Location header. This status code is similar to the HTTP 301 status code, but with the key difference that it maintains the HTTP method and the body of the original request.

Key Points about HTTP 308:

  1. Permanent Redirection: The resource requested has been permanently moved to the new URL.
  2. Method Preservation: The original request method (e.g., GET, POST, PUT) and the body are preserved when the client makes the new request to the new URL. This is different from the HTTP 301 status code, where the method may change (e.g., POST to GET).
  3. Location Header: The new URL is specified in the Location header of the response.
  4. SEO Friendly: Like HTTP 301, using HTTP 308 for permanent redirection can help with search engine optimization by ensuring search engines update their indexes with the new URL.

Example of an HTTP 308 Response:

HTTP/1.1 308 Permanent Redirect
Location: https://new-example.com/resource 

In this example, the client is informed that the resource it is trying to access has been permanently moved to https://new-example.com/resource, and it should use this URL for future requests while keeping the same HTTP method and request body.

What is the Difference Between HTTP 301 and 308 Status Code?

The key difference between HTTP 301 and HTTP 308 status codes is that HTTP 301 may change the HTTP method from POST to GET during redirection, while HTTP 308 preserves the original HTTP method and request body.

HTTP 301 Status Code

  1. Permanent Redirect:

    • The HTTP 301 status code indicates that the requested resource has been permanently moved to a new URL provided by the Location header.
  2. Method Change:

    • HTTP 301 redirects may change the HTTP method from POST to GET. This means that if the original request was a POST, the redirected request will be a GET.
  3. SEO Friendly:

    • HTTP 301 redirects are recognized by search engines as a signal that the URL has permanently moved. This helps in passing the SEO value from the old URL to the new URL.
  4. Typical Use Case:

    • HTTP 301 is often used when a webpage has been moved to a new location and it is acceptable to convert POST requests to GET requests.

Example:

HTTP/1.1 301 Moved Permanently
Location: https://new-example.com/resource

HTTP 308 Status Code

  1. Permanent Redirect:

    • The HTTP 308 status code also indicates that the requested resource has been permanently moved to a new URL provided by the Location header.
  2. Method Preservation:

    • Unlike HTTP 301, HTTP 308 preserves the original HTTP method and the request body. This means that if the original request was a POST, the redirected request will also be a POST with the same body.
  3. SEO Friendly:

    • HTTP 308 redirects are also recognized by search engines as a signal that the URL has permanently moved, ensuring that the SEO value is passed from the old URL to the new URL.
  4. Typical Use Case:

    • HTTP 308 is particularly useful for scenarios where it is important to maintain the original HTTP method and request body, such as form submissions or API requests.

Example:

HTTP/1.1 308 Permanent Redirect
Location: https://new-example.com/resource

Key Points of Comparison:

  1. Method Handling:

    • HTTP 301: May change POST requests to GET.
    • HTTP 308: Preserves the original HTTP method (e.g., POST remains POST).
  2. Use Case Suitability:

    • HTTP 301: Suitable for general permanent redirects where method preservation is not critical.
    • HTTP 308: Suitable for permanent redirects where it is crucial to preserve the HTTP method and request body.
  3. SEO Implications:

    • Both HTTP 301 and HTTP 308 are SEO-friendly and help in passing the link equity and search engine ranking from the old URL to the new URL.

Importance of the HTTP 308 Status Code in SEO

The HTTP 308 status code plays a significant role in SEO (Search Engine Optimization) due to its impact on how search engines handle and index web pages. Here’s why it’s important:

  1. Permanent Redirection: The HTTP 308 status code indicates a permanent change in the URL of a resource. This tells search engines to replace the original URL with the new URL in their indexes, maintaining the search engine ranking of the original page and transferring link equity to the new URL.
  2. Preserves HTTP Method and Body: Unlike the HTTP 301 status code, which might change the request method from POST to GET, the HTTP 308 status code preserves the original HTTP method and the request body, which is important for maintaining user experience and the functionality of forms and APIs.
  3. Maintaining Link Equity: When search engines encounter a 308 redirect, they understand that the original URL's authority and link equity should be passed to the new URL, ensuring backlinks continue to benefit the site's overall SEO.
  4. Avoiding Duplicate Content: Using a 308 status code helps avoid duplicate content issues, ensuring that only the new URL is indexed, which prevents ranking dilution.
  5. User Experience: A smooth redirection process ensures that users and search engines do not encounter errors or interruptions, indirectly benefiting SEO by reducing bounce rates and improving engagement metrics.

Example Scenario:

Imagine you have an e-commerce site and you permanently move a product page from /old-product-url to /new-product-url. Using a 308 status code in this scenario will:

  • Inform search engines that the product has a new permanent URL.
  • Preserve the POST method if the redirection involves submitting form data (e.g., user reviews).
  • Ensure that any existing backlinks to /old-product-url pass their SEO value to /new-product-url.
  • Prevent the old URL from being indexed, avoiding duplicate content issues.

How to Use HTTP 308 Status Code for a Website?

Implementing the HTTP 308 status code for permanent redirects on your website involves configuring your web server to respond with a 308 status code and specifying the new URL in the Location header. Here’s how to do it for different web servers:

Apache

.htaccess File:

  1. Locate the .htaccess file in your website’s root directory. If it doesn’t exist, create it.
  2. Add the following lines to set up a permanent redirect:
    RewriteEngine On
    RewriteRule ^old-page$ https://example.com/new-page [R=308,L]
    

httpd.conf:

  1. Open your httpd.conf file.
  2. Add the following lines to configure a permanent redirect:
    Redirect 308 /old-page https://example.com/new-page 

Nginx

nginx.conf:

  1. Open your nginx.conf file or the relevant server block configuration file.
  2. Add the following lines to set up a permanent redirect:
    server {
        listen 80;
        server_name example.com;
    
        location /old-page {
            return 308 https://example.com/new-page;
        }
    

IIS (Internet Information Services)

Web.config:

  1. Locate or create a web.config file in your website’s root directory.
  2. Add the following XML configuration to set up a permanent redirect:
    <configuration>
        <system.webServer>
            <httpRedirect enabled="true" destination="https://example.com/new-page" httpResponseStatus="Permanent" />
        </system.webServer>
    </configuration>
    

Using PHP

If you prefer to handle redirections within your PHP code:

PHP Script: Add the following code at the top of your PHP file:

<?php
if ($_SERVER['REQUEST_URI'] == '/old-page') {
    header("Location: https://example.com/new-page", true, 308);
    exit();
}
?>

General Steps

  1. Identify the Old and New URLs: Determine the URL paths you need to redirect.
  2. Update Server Configuration: Depending on your server type, use the appropriate method to implement the 308 redirect.
  3. Test the Redirect: After making the changes, test the redirection by visiting the old URL to ensure it correctly redirects to the new URL with a 308 status code. Use browser developer tools or online HTTP status checkers to verify the status code.
  4. Update Internal Links: Update any internal links on your website to point directly to the new URL to avoid unnecessary redirects.
  5. Monitor SEO Impact: Use tools like Google Search Console to monitor how search engines handle the redirection and ensure that the new URL gets indexed properly.

How to Check HTTP 308 Status Code?

Checking for an HTTP 308 status code can be done using various methods, including browser developer tools, command-line tools, and online HTTP status checkers. Here are some of the most common ways to check for an HTTP 308 status code:

Using Browser Developer Tools

Google Chrome:

  1. Open Chrome and go to the page you want to check.
  2. Right-click on the page and select "Inspect" or press Ctrl+Shift+I.
  3. Go to the "Network" tab.
  4. Reload the page.
  5. Look for the request in the list and click on it. Check the "Status" column for the 308 status code and the "Headers" tab for the Location header.

Firefox:

  1. Open Firefox and navigate to the desired page.

  2. Right-click on the page and select "Inspect Element" or press Ctrl+Shift+I.
  3. Go to the "Network" tab.
  4. Reload the page.
  5. Find the request in the list and click on it. Check the "Status" column and the "Headers" tab for details.

Using Command-Line Tools

cURL:

  1. Open your terminal or command prompt.
  2. Use the curl command with the -I option to fetch the headers:
    curl -I http://example.com/old-page 
  3. Look for the HTTP/1.1 308 Permanent Redirect line in the output, indicating the 308 status code, and the Location header for the new URL.

wget:

  1. Open your terminal or command prompt.
  2. Use the wget command with the --server-response option:
    wget --server-response http://example.com/old-pag
    
  3. Check the output for the HTTP/1.1 308 Permanent Redirect status code and the Location header.

Using Online HTTP Status Checkers

Several online tools can check HTTP status codes and headers. Here are a few:

TechSEOHub Tools:

  1. Visit HTTP Status Checker.
  2. Enter the URL you want to check.
  3. Click on "Check Status."
  4. The tool will display the status code and headers, including any 308 redirects.

WebConfs HTTP Header Checker:

  1. Visit WebConfs HTTP Header Checker.
  2. Enter the URL you want to check.
  3. Click on "Check Headers."
  4. Review the results for the 308 status code and the Location header.

Using Programming Languages

Python (using requests library):

  1. Install the requests library if you haven't already:
    pip install request
    
  2. Use the following Python script to check the status code:
    import requests
    
    response = requests.get('http://example.com/old-page', allow_redirects=False)
    print(response.status_code)
    print(response.headers['Location']
    

JavaScript (using Fetch API in a browser console):

  1. Open the browser console (F12, then go to the "Console" tab).

  2. Run the following code:
    fetch('http://example.com/old-page', { method: 'GET', redirect: 'manual' })
      .then(response => {
        console.log('Status:', response.status);
        console.log('Location:', response.headers.get('Location'));
      });
    

These methods will help you verify whether a URL is responding with an HTTP 308 status code and where it is redirecting to.

Which HTTP Method is used with HTTP 308 Status Code?

The HTTP 308 status code is used to indicate a permanent redirect, and it is unique in that it preserves the original HTTP method and request body. This means that whatever HTTP method was used in the original request (e.g., GET, POST, PUT, DELETE) will be maintained when the client is redirected to the new URL.

Key Points:

  • Method Preservation: Unlike the HTTP 301 status code, which can change the method from POST to GET during the redirection process, the HTTP 308 status code ensures that the original HTTP method is preserved. This is crucial for requests that are not idempotent, such as POST requests, to ensure that the request's intent and data are not altered during the redirection.
  • Use Cases: This preservation of the method and request body makes HTTP 308 particularly useful for scenarios where the request contains significant data or when the same type of request needs to be made to a new URL.

What is the Browser Compatibility of HTTP 308 Status Code?

The HTTP 308 status code is generally well-supported across modern browsers, but it's always good to be aware of specific compatibility details to ensure that your web applications behave as expected. Here is an overview of the browser compatibility for the HTTP 308 status code:

Browser Compatibility

  1. Google Chrome:

    • Supported: Yes
    • Version: Supported since Chrome 23
  2. Mozilla Firefox:

    • Supported: Yes
    • Version: Supported since Firefox 26
  3. Microsoft Edge:

    • Supported: Yes
    • Version: Supported since Edge 15
  4. Apple Safari:

    • Supported: Yes
    • Version: Supported since Safari 11
  5. Opera:

    • Supported: Yes

    • Version: Supported since Opera 15
  6. Internet Explorer:

    • Supported: No
    • Notes: Internet Explorer does not support HTTP 308. Users will need to rely on other methods or consider using alternative status codes like 301 or 302 for compatibility with IE.

Detailed Notes:

  • Chrome: Full support for HTTP 308 since version 23. It handles the method preservation correctly, ensuring that the original method (e.g., POST) is used after the redirect.
  • Firefox: Full support since version 26. Similar to Chrome, it preserves the original request method.
  • Edge: Full support since Edge 15. The Edge browser correctly handles HTTP 308 redirects and preserves the request method.
  • Safari: Full support since version 11. Safari handles HTTP 308 redirects properly, including method preservation.
  • Opera: Opera has supported HTTP 308 since version 15. It correctly preserves the request method during redirection.
  • Internet Explorer: Does not support HTTP 308. For IE users, consider using HTTP 301 or 302 if method preservation is not critical, or provide alternative handling through server-side logic or client-side scripting.

Testing Browser Compatibility:

To ensure your application handles HTTP 308 correctly across different browsers:

  1. Use Browser Developer Tools:

    • Check the Network tab to see how different browsers handle the HTTP 308 status code and verify that the request method and headers are preserved.
  2. Use Online Testing Tools:

    • Websites like BrowserStack or CrossBrowserTesting can help you test your web application on various browser versions and platforms.
  3. Monitor Analytics:

    • Use analytics tools to monitor user behavior and identify any issues related to redirects. If you see unexpected patterns or errors, investigate further to ensure compatibility.

Best Practices for Handling HTTP 308

Handling HTTP 308 status codes effectively involves following best practices to ensure smooth redirections, maintain SEO benefits, and provide a consistent user experience. Here are some best practices to follow:

  1. Use When Permanent and Method-Preserving Redirects Are Needed:

    • Appropriate Use Cases: Employ HTTP 308 for permanent redirections where it’s crucial to preserve the original HTTP method and request body. This is especially important for non-idempotent requests like POST.
  2. Set Up Proper Server Configuration:

    • Web Server Configuration: Ensure your web server is configured correctly to handle HTTP 308 redirects.
      • Apache (.htaccess or httpd.conf):
        RewriteEngine On
        RewriteRule ^old-page$ https://example.com/new-page [R=308,L]
        
      • Nginx (nginx.conf):
        server {
            listen 80;
            server_name example.com;
        
            location /old-page {
                return 308 https://example.com/new-page;
            }
        }
        
      • IIS (Web.config):
        <configuration>
            <system.webServer>
                <httpRedirect enabled="true" destination="https://example.com/new-page" httpResponseStatus="Permanent" />
            </system.webServer>
        </configuration> 
  3. Ensure SEO Benefits:

    • Update Internal Links: Update all internal links to point directly to the new URL to avoid unnecessary redirects.
    • Submit Updated Sitemaps: Submit an updated sitemap to search engines to help them discover the new URLs faster.
    • Monitor Search Engine Indexing: Use tools like Google Search Console to monitor how search engines are indexing the new URLs and ensure that the old URLs are removed from the index.
  4. Test Thoroughly:

    • Verify Redirection: Test the redirection using browser developer tools to ensure it works as expected and the HTTP method and body are preserved.
      • Chrome/Firefox Developer Tools: Inspect the Network tab for the 308 status code and Location header.
      • Command-Line Tools:
        • cURL:
          curl -I http://example.com/old-page 
        • wget:
          wget --server-response http://example.com/old-page
          
    • Cross-Browser Testing: Verify the redirect works across all major browsers and versions that your users might use.
  5. Fallback for Unsupported Browsers:

    • Internet Explorer Handling: Since Internet Explorer doesn’t support HTTP 308, provide alternative handling for these users. You can use HTTP 301 or 302 for compatibility or use JavaScript to handle redirects in unsupported browsers.
      • JavaScript Fallback:
        if (navigator.userAgent.indexOf('MSIE') !== -1 || !!document.documentMode) {
            window.location.href = 'https://example.com/new-page';
        }
        
  6. Monitor and Analyze:

    • Analytics Monitoring: Use web analytics tools to monitor traffic and ensure that the redirects are functioning correctly. Look for any issues such as increased bounce rates or user drop-offs.
    • Server Logs: Regularly check server logs to identify any issues with redirects and ensure they are being processed as expected.
  7. User Experience:

    • Consistent User Experience: Ensure that users are seamlessly redirected to the new URL without any interruptions or errors. This is particularly important for POST requests where preserving the method and data is critical.

Conclusion

The HTTP 308 status code is a powerful tool for managing permanent redirects while preserving the original request method and body. By correctly implementing and handling HTTP 308 redirects, you can ensure a smooth user experience, maintain SEO benefits, and effectively communicate permanent URL changes to search engines. Proper configuration, thorough testing, and monitoring are key to making sure your redirections work smoothly across all supported browsers. Following these best practices will help you leverage HTTP 308 redirects effectively, enhancing both your site’s performance and user satisfaction.

Oskay Günaçar
Oskay Günaçar is a Technical SEO expert and backend developer. His main areas of interest are back-end programming, Python, Django, Go, semantic SEO, technical SEO. With more than 5 years of SEO experience, he has held SEO specialist positions at İkiler, Webtures, Boosmart, and Storyly.io companies, and has been involved in numerous projects as an outsourced expert. Through the TechSEOHub website, he aims to share the expertise and experience he has gained from managing and developing (SEO) processes for many successful and large websites in the industry, and to produce content for easy access to accurate and high-quality information.