Redirecting web pages is an essential task that requires careful consideration of the various HTTP status codes. the 307 Temporary Redirect, can be utilized to great effect – but you must know when and how to use it properly for maximum efficiency. In this article we will explore what a HTTP 307 redirect does exactly, its differences from other temporary redirects, and its potential impact on SEO.
What are the http status codes
HTTP status codes are three-digit numbers that are returned by a web server in response to a client’s request using Hypertext Transfer Protocol (HTTP). These codes indicate the status of the request and whether it was successful or not. Some common status codes include 200 OK, 404 Not Found, and 500 Internal Server Error.
These codes can be separated into five classes, with the initial digit in each http status code showing which class it falls into. Here is an overview of these categories:
- 1xx: Informational – These codes verify that your request has been acknowledged and is currently being processed.
- 2xx: Successful – An indication of success, these codes signify that the requested resource is being sent back to you. You can rest assured knowing that your request has been fulfilled!
- 3xx: Redirection – To complete the request, clients must adhere to these codes that signify further steps of action.
- 4xx: Client Error – These codes demonstrate that the client’s inquiry contained a mistake, such as an excluded or incorrect parameter.
- 5xx: Server Error – These codes signalize that the server encountered an issue and couldn’t process the initial request.
What is HTTP 307 Temporary Redirect Status Code
When it comes to redirecting web pages, the HTTP 307 Temporary Redirect status code indicates that the target resource resides temporarily in a different location. The client should continue to use the original URL to access the resource and resubmit the original request method, but the server will redirect the client to the new location using the ‘location’ response header for a limited amount of time. The user agent will automatically follow the redirected request on the HTTP response status codes. This is known as a “temporary redirect.”
How a 307 Redirect Works
When a client sends an HTTP request method to access a resource that has been temporarily moved, the server will return a 307 status code along with the new location of the resource in the ‘location’ field value. The user agent’s browser will then automatically redirect the user to the new location, but will continue to use the original URL for future requests. This allows for the resource to be moved temporarily without affecting the user’s experience or causing issues for search engines.
When to use 307 temporary redirect?
There are plenty of circumstances in which a HTTP 307 Temporary Redirect can be beneficial. To name a few:
- If a resource needs to be inaccessible for a short period of time, you can direct users to an alternate page with the use of a 307 redirect. For instance, if your website is undergoing maintenance but will return within several hours, people visiting the site will instead land on your maintenance page until it’s accessible again.
- A 307 redirect can be utilized to guide customers to the new location if a resource is being relocated temporarily, such as when migrating a website from one domain name to another. This allows users to follow the old URL without disrupting its usability.
- If a resource is in the process of being updated, such as when changes are not yet live on a website, 307 redirects enable you to direct users to an informative “coming soon” page until all updates have been completed.
- If a particular website service is not available in certain areas, redirect those who try to access it from other places with the use of a 307 redirect. This will lead users elsewhere and show them an “access denied” page instead.
- If you want to ensure access to a resource is limited only during certain timeframes, then the 307 redirect can come in handy. Say for instance, you have an online website open exclusively during business hours; outside of those times it’ll automatically route users towards a “closed” page instead so that any unexpected visits will still be handled appropriately.
- Utilizing a 307 redirect when running an A/B test is invaluable because it enables users to be sent to the ideal version of the page based on their individual demo- and psychographics. For instance, if you’re testing different versions of your website across multiple visitors, you can use this type of redirect so that those visitors are redirected properly.
How to implement a Temporary Redirect
You can use several strategies to implement a 307 Temporary Redirect on your website. These include: editing the .htaccess file (if you are using an Apache server), updating the backend of your website, or utilizing a plugin (WordPress).
via Your .htaccess File
Setting up a 307 Temporary Redirect using the .htaccess file is an uncomplicated task. This server configuration document provides control over several aspects of your website, as well as redirects.
Here is an example of how you can use the .htaccess file to execute a 307 Temporary Redirect:
- The first step is to find the .htaccess file located in your website’s root directory. This should be relatively straightforward, as it is often stored there by default.
- Launch your preferred text editor – whether that’s Notepad, Sublime Text, or something else – and open up the .htaccess file.
- Add the following line of code to the file:
Redirect 307 /old-url https://www.test.com/new-url
By using this line of code, you can seamlessly redirect visitors from the “old-url” to a new address at “new-url”, and serve them with a 307 Temporary Redirect status code.
- Once you’ve saved the .htaccess file, upload it to your server and enjoy its benefits!
- To check if your redirect is working properly, try entering the “old-url” in your web browser. You should be instantly directed to the designated “new-url”, with a 307 status code displayed at the top of your page.
It is essential to bear in mind that the .htaccess file will only work on Apache servers. If your website functions with another type of web server, this approach might not be successful. Furthermore, verify you have the needed permissions for editing the .htaccess file and make a backup before making any changes – these are both vital steps!
Implement a 307 Temporary Redirect on Your Website
Setting up a 307 Temporary Redirect on your website is also simple and depends entirely upon the type of programming language and framework being used.
Here is an example of how you can use PHP to implement a 307 Temporary Redirect:
- Open the PHP file that handles the request for the resource that you want to redirect.
- Add the following lines of code to the top of the file:
header("HTTP/1.1 307 Temporary Redirect"); header("Location: https://www.example.com/new-url");
By using this code, you can quickly and efficiently redirect the client to a new location. A 307 Temporary Redirect status code will be sent with the resource’s updated address.
- Save the file and upload it to your server.
- To ensure the success of your redirect, test the original URL in your web browser. You ought to be automatically routed to its new destination with a 307 status code without any issue.
It’s essential to remember that the example provided is for PHP, and could differ when it comes to other languages, frameworks or platforms. Moreover, you must have explicit permissions before making any modifications and backing up your file as a precautionary measure.
When working with certain web frameworks, such as Ruby on Rails, you can utilize the redirect_to method to seamlessly direct users to a different URL. This streamlined process also sets the correct status code for your website. As an added bonus, this will save time and energy when attempting to efficiently navigate users throughout your site’s pages!
Using a Plugin
If you’re using a Content Management System (CMS) like WordPress, then the usage of 307 Temporary Redirect plugins is an ideal method for redirecting without having to write code. There are multiple plugins available such as Simple 301 Redirects plugin, Redirection Plugin, and more so that you can conveniently perform your desired redirects.
Utilize the Simple 301 Redirects plugin to quickly and easily implement a 307 Temporary Redirect; here is an example of how you can do so:
- Install and activate the Simple 301 Redirects plugin on your WordPress website.
- Go to the Settings > 301 Redirects page in your WordPress dashboard.
- Enter the old URL in the “Request” field and the new URL in the “Destination” field, and choose the “307” option in the “Redirection type” field.
- Click the “Add Redirect” button to save the redirect.
- Test your redirect by visiting the old URL in your browser. You should be automatically redirected to the new location with a 307 status code.
It is essential to note that this example applies solely for the Simple 301 Redirects plugin, and other plugins may require a different process. Similarly, it’s critical to make sure you have legitimate permission from your web host before installing or activating any plugin on your website.
Prior to implementing redirects, it is absolutely essential that you test them out and make sure there are no broken links or 404 errors. Additionally, some plugins provide more advanced options than others such as logging redirects, tracking clicks and much more – so be sure to read the plugin’s documentation closely and ensure they meet your needs before utilizing them.
302 vs 303 vs 307 for Temporary Redirects
Choosing the right temporary redirect HTTP status code for your website can appear perplexing – from 302s to 303s and 307s. However, every one of these codes serves a unique purpose and needs to be followed precisely by the client so that it executes properly.
- If you’re looking for a web resolution that indicates the temporary relocation of your requested resource, the 302 Found status code is perfect. Referred to as a “302 redirect,” this code will direct all future requests from clients to use the original URL while simultaneously being redirected toward the new location for their current request.
- Whenever you encounter the 303 See Other status code, it indicates that your requested resource has been relocated temporarily, and future requests should be made to this new location only. The original URL must no longer be used for any further requests.
- The HTTP 307 Temporary Redirect status code operates similarly to the 302, however, it mandates that the client resubmit their initial request with its message body intact (i.e., a POST request). This is especially beneficial for requests like those requiring an exchange of information or data in order to proceed.
HTTP 307 Redirects and SEO
Be cautious when dealing with redirects for your website if you want to preserve SEO. Unmanaged 307 Temporary Redirect status codes can be damaging to your search engine rankings and visibility, so it is essential that they are used correctly.
A major problem with 307 redirects is that it can result to duplicate content. This happens when the original URL and its new location both contain similar information. To prevent this from occurring, make sure you use a 301 Permanent Redirect rather than a 307 Temporary Redirect at all times where possible.
Furthermore, make sure that the redirects on your website are correctly set up and don’t result in broken links or 404 errors. Otherwise, it could lead to a decrease in search engine rankings for your site.
Ultimately, 307 Temporary Redirects can be beneficial in specific cases; however, utilizing 301 Permanent Redirects is the more preferable option. Moreover, make sure all website redirects are correctly set up to avoid any broken links and 404 errors that could negatively affect your SEO rankings.
All HTTP status codes by categories
(100 – 199)
(300 – 399)
(400 – 499)
404 Not Found