What is a 307 Redirect and How to Use It?
When you manage a website, it’s important to be aware of the different Hypertext Transfer Protocol (HTTP) status codes you might encounter. While some are errors, others like the “307 redirect” are essential to ensuring that visitors can successfully access your URLs (and that you don’t get penalized by search engines ).
However, this isn't the only redirect available, so you might be wondering when it's appropriate to use it. In this article, we'll talk in detail about 307 redirects. We'll explain what they are, when to use them, and some key tips for doing so effectively.
What is a 307 Redirect?
A 307 Temporary Redirect is an HTTP status code that indicates a temporary change in the location of a web page or resource. Essentially, it’s a way to tell browsers and search engine crawlers: “The content you’re looking for isn’t here right now, but you can temporarily find it at this other address. Please come back to this page later, as the original URL will be active again.”
Crucially, unlike other types of redirects, a 307 Redirect tells browsers to repeat the original request method when accessing the temporary URL. This means that if the original request used the POST method (for example, when submitting a form), the browser will use POST again at the temporary location. This detail is essential for maintaining website functionality, especially for forms and other interactive elements.
HTTP Status Codes 307 Temporary Redirects belong to the 3xx class of HTTP status codes, which indicate some kind of redirection. Here is a quick overview of the most common redirect codes you might encounter:
301 (Permanent Redirect): Signals a permanent change. Search engines will update their indexes and transfer SEO value to the new URL.
302 (Found / Temporary Redirect): Used for very temporary relocations. Some older browsers may need to change the request method to GET.
307 (Temporary Redirect): Indicates a temporary change, preserving the original request method. This is the ideal option in many scenarios, which we will discuss later.
308 (Permanent Redirect): Similar to 301, but specifically preserves the original request method.
When to Use 307 Temporary Redirects?
Website Maintenance
Downtime happens, whether it’s due to scheduled updates, upgrades, or unexpected failures. 307 redirects are your best friend in these cases. By temporarily redirecting users from affected pages or the entire site to a “maintenance mode” page, you can:
Minimize frustration: Visitors should be informed about error messages. Instead, they should be politely informed about the situation and given an estimated time of return.
Preserve SEO: Search engines understand the temporary nature of the redirect, minimizing any negative impact on your rankings.
Temporary Relocation of Content
Sometimes you need to move content temporarily for various reasons:
Seasonal Campaigns: Drive traffic to holiday-themed landing pages or special promotions without disrupting your site's regular structure.
A/B Testing: Experiment with different versions of a page, redirecting a portion of traffic to the alternative for analysis.
Content Updates: Make major revisions to a page without affecting the live version until you're happy with the changes.
307 redirects ensure that users can still find the content they're looking for while you're working on changes behind the scenes.
Site Migrations
Moving your website to a new domain or hosting provider is a multi-step process. 307 redirects play a vital role in ensuring a smooth transition:
Domain Changes: While DNS changes propagate, use 307 redirects to seamlessly direct visitors from your old domain to your new domain.
Server Migrations: If you're upgrading your hosting (for example, moving to Elementor Hosting for increased performance and scalability), 307s will keep your website accessible during the transition.
Pro Tip: Elementor Hosting offers free site migration and easy-to-use site cloning tools, making the technical side of migrations much easier along with redirects.
Development and Testing
Creating a great website often involves iteration and experimentation. This is where 307s help:
Staging Environments: Set up a staging site to test significant changes or plugin updates without risking the live site. Use 307s to redirect only specific users (developers, testers) to the staging version.
Live Previews: Sometimes you need to get feedback from clients on changes before making them public. A 307 redirect to a temporarily modified version of a page allows for the preview and approval process.
Troubleshooting Broken Links and 404 Errors
Broken links (which lead to the dreaded 404 “Not Found” errors) are a nightmare for a good user experience. They can occur due to deleted pages, changed URLs, or typos. Here’s how 307s come to the rescue:
Temporary Solutions: Suppose a page needs to be temporarily taken down, but you know it will be back. Implement a 307 redirect to a similar page or a temporary bookmark informing users when the original content will return.
Content Restructuring: If you've reorganized your site's hierarchy, 307s can gently guide users and search engines from old URLs to their new locations.
External Link Issues: While you can't control external websites, you can use 307s to temporarily redirect users away from broken third-party links, providing a better experience.
While 307s mitigate the immediate frustration of broken links, it's essential to address the root cause. Plan to restore lost content, create permanent redirects (301) if URLs have permanently changed, or remove outdated links.
When to Avoid Using 307 Redirects?
While 307 status codes can help maintain security and benefit user experience, they are certainly not a one-size-fits-all solution to use across your entire site. In fact, if not used in the right scenario, 307 redirects can have a negative impact on site functionality and user experience.
Permanent URL Changes: Search engines interpret 307 redirects as tempor north korea business email list ary, so if you intend for the redirect to have long-term SEO effects, such as transferring link equity to the new URL, a 307 redirect could make that difficult.
The 301 status code is the only one to use when the intent is to permanently move one URL to another.
Site-Wide Redirects: Using 307 status codes for site-wide or bulk redirects could impact server performance, especially on high-traffic sites. Processing a large number of temporary redirects can drain server resources and slow down site response times, ultimately impacting SEO and user experience.
How to Set Up a 307 Redirect?
How you set up a 307 redirect depends on your website platform (e.g. WordPress, Joomla, or custom), your technical expertise, and your specific goals for the temporary redirect.
Here are the four most common methods:
1. Edit the .htaccess File
The .htaccess file is a configuration file that tells your server (assuming you're using Apache) how to respond to various scenarios, including redirects.
You can implement a 307 redirect by modifying this file.
Log in to your website's hosting account, go to the file manager, and then navigate to the root directory (the main folder of your website).
public_html folder in Bluehost File Manager Locate the .htaccess file inside the root directory and select it to edit.
.htaccess file selected and edit button highlighted Now do the following:
Look for a line that says “RewriteEngine On” (see screenshot below). If it’s not there, consider adding it (you don’t strictly need it for this example, but it’s necessary for adding rewrite rules).
Add the following code to the end of your .htaccess file: Redirect 307 /oldpage.html /newpage.html Make sure to replace “/oldpage.html” with the relative URL of the page you are redirecting from and “/newpage.html” with the relative URL of the target page.
Save the file. And test to see if the redirection works.
2. Try PHP Redirect
Using PHP headers is another way to do a server-side redirect.
To set up a 307 redirect using PHP, use the “header()” function to send a location header to the browser and tell it to redirect to a new URL.
Open the PHP file that corresponds to the page you want to redirect.
At the top, insert this before any other content:
<?php header(“Location: /new-url/”, true, 307); exit; ?>
Replace “/new-url/” with the desired destination URL (this can be a relative URL as shown above) and save the file. Test the redirect by accessing the original page.