What Is a 307 Redirect?
A 307 redirect (also known as “307 short-term redirect”) is an HTTP standing code that quickly diverts web site guests from one URL to a different. The 307 standing code generally is a great tool for website upkeep, content material updates, and extra.
However mismanaging it will probably result in:
- Web site errors
- Decrease rankings on search engine outcome pages (SERPs)
- Poor consumer expertise
On this article, you’ll find out how the 307 redirect works, when to make use of it, easy methods to set it up, and a few finest practices.
We’ll additionally clarify 307 inside redirect, which isn’t an HTTP standing code however performs a job in web site safety.
Let’s begin by trying on the wider household of 3xx standing codes.
Understanding the 3xx Standing Codes
All HTTP standing codes with a 3xx quantity cope with URL redirection.
How do they work?
When somebody tries to entry your webpage, their browser forwards a “request” to your website’s server (a system that hosts and delivers net content material).
The server responds with a message indicating the web page’s standing. This message is known as an HTTP standing code.
If there’s a purpose for the browser to be guided to a unique location, the server sends a 3xx standing code.
Listed here are the 3xx codes in simplified type:
- 300 a number of decisions: The browser can select between a number of choices for the requested web page
- 301 moved completely: The requested web page has a brand new everlasting tackle
- 302 discovered: The requested web page has a brand new tackle for a short while
- 303 see different: After an motion like submitting a type, the consumer is distributed to a different web page to forestall duplicate submissions
- 304 not modified: The requested web page hasn’t modified because the consumer’s final go to, so the browser can use its cached model
- 307 short-term redirect: The requested web page is quickly at a unique tackle
- 308 everlasting redirect: The requested web page has moved completely
The 302, 303, and 307 codes are short-term redirects. So how are they completely different?
302, 303, and 307 Redirects: What is the Distinction?
There are three forms of short-term 3xx redirects: 302, 303, and 307. Every has a novel perform.
The primary distinction between these redirects is how they deal with GET and POST requests—two widespread forms of requests despatched by a browser to a server when a consumer tries to entry a webpage:
- GET: When a consumer solely desires to view a web page
- POST: When a consumer desires to ship information to the server (e.g., when submitting a type)
302 Redirect
When a consumer tries to submit a type or different information (a POST request), the 302 redirect would possibly change the request to a GET request.
This may battle with the consumer’s intention.
For example, if a consumer is attempting to join a publication, their electronic mail may not be added to the subscription listing as a result of change in request kind.
303 Redirect
The 303 standing code turns all request sorts right into a GET request. It’s thought of short-term as a result of it’s tied to solely certainly one of a number of actions accessible to a website customer, resembling submitting a type.
After a type submission, the 303 code sends the consumer to a unique location utilizing a GET request. This avoids the danger of resubmission if the consumer hits the refresh button.
However by turning all request sorts right into a GET request, the 303 standing code can battle with the consumer’s intent. For this reason the 303 redirect isn’t broadly used.
307 Redirect
Not like the 302 and 303 codes, the 307 redirect maintains the integrity of the unique request methodology. A POST request, for instance, stays a POST request after the redirect.
Sustaining the proper request kind ensures that type submissions and different despatched information attain their supposed vacation spot and permits the web site to higher shield delicate consumer data.
Though all three redirects point out a brief transfer, the 307 standing code is your best option, particularly when information submission is concerned.
307 Non permanent Redirect vs. 307 Inner Redirect
A 307 short-term redirect is a server-side instruction that tells browsers to quickly redirect site visitors from one URL to a different. It is a short-term measure.
A 307 inside redirect is not an official HTTP standing code however is typically utilized in net server configurations. It’s a browser-initiated redirect for a really particular function: to direct guests away from the HTTP model of your website to the safer HTTPS model.
It’s a everlasting safety measure to guard consumer information.
When somebody visits your web site, their browser communicates together with your web site’s server. This communication may be:
- HTTP: A plain-text communication protocol
- HTTPS: An encrypted communication protocol, the place the “S” stands for “safe”
Each web site has a non-secure HTTP model. However if you happen to’ve carried out safety practices, you’ve got an HTTPS model, too.
Nonetheless, simply having an HTTPS website is not sufficient. Guests may nonetheless land in your HTTP website. To stop this, you want a seamless redirect to your HTTPS model. That is the job of the 307 inside redirect.
By enabling HSTS (HTTP Strict Transport Safety), you may set off these 307 inside redirects in a customer’s browser.
HSTS is a safety function that instructs browsers to all the time use HTTPS as a substitute of HTTP.
The outcome: When a consumer tries to entry your website by way of HTTP, the browser mechanically redirects them to the HTTPS model.
Utilizing the 307 inside redirects by way of HSTS ensures that customers’ information stays encrypted and safe from potential threats.
The right way to Set Up a 307 Redirect
There are a number of methods to implement a 307 redirect. The tactic of alternative is determined by your website’s platform (e.g., WordPress, Joomla, custom-built), your technical experience, the instruments you are comfy with, and your particular objectives for the short-term redirect.
Listed here are the three most typical strategies:
1. Enhancing the .htaccess File
The .htaccess file is a configuration file primarily utilized by Apache net servers.
This file instructs your server how to answer numerous situations, together with redirects.
You possibly can implement a 307 redirect by modifying this file.
Amongst different advantages, the .htaccess file offers you centralized management. You possibly can conveniently handle all of your redirects from this single file. Different strategies require organising every redirect individually.
Log in to your web site’s internet hosting account. Then navigate to the basis listing, which is your web site’s essential folder.
For instance: If Bluehost is your hosting supplier, your root listing will look one thing like this:
Find the .htaccess file contained in the “public_html” folder. Open it to edit.
Now do the next:
- Examine if “RewriteEngine” is on. You will see a line within the file that claims RewriteEngine On. (See the screenshot beneath) If it is not there, you might want to add it.
- Add the next code on the finish of the .htaccess file:
Redirect 307 /oldpage.html /newpage.html
Be certain to substitute /oldpage.html with the trail of the web page you are redirecting from and /newpage.html with the vacation spot web page’s path.
Save the file. And take a look at to see whether or not the redirect is working correctly.
If you’re utilizing a server kind apart from Apache (e.g., Nginx or IIS), the method is completely different. However the precept stays the identical: You will have to edit a configuration file particular to that server.
Be certain to verify your server’s documentation or search professional recommendation.
2. Plugins
Does your website use a content material administration system (CMS) resembling WordPress? Then implementing a 307 redirect is simple by way of a plugin.
Merely seek for a redirection plugin in your CMS’s plugin retailer or on third-party platforms.
Set up and activate the plugin. Then observe its directions.
Let’s take WordPress for instance.
The Redirection plugin is a well-liked free answer for dealing with your redirects.
Log in to your WordPress dashboard. Click on “Plugins” within the sidebar, seek for “redirection,” and activate it.
Then head to “Instruments” > “Redirection” to open the plugin.
Now enter your 307 redirect guidelines.
Additional studying: The right way to Redirect URLs on WordPress
3. Programming Languages
Programming languages supply a extra hands-on strategy to organising redirects.
This methodology is good in order for you direct management over how and when redirects occur. Programming languages allow you to redirect customers primarily based on particular actions they take or particulars they supply.
In addition they enable for sooner and extra built-in setups with out the necessity for extra instruments or plugins.
PHP and JavaScript are two widespread languages. Right here’s how you need to use them to implement 307 redirects:
Redirects in PHP
PHP is a server-side scripting language generally utilized in net improvement.
To arrange a 307 redirect utilizing PHP, use the “header()” perform to ship a location header to the browser, instructing it to redirect to a brand new URL.
Open the PHP file from which you need to redirect.
On the high, earlier than any content material, insert:
<?php
header("Location: /new-url/", true, 307);
exit;
?>
Exchange /new-url/ together with your desired vacation spot.
Save the file and take a look at the redirect by accessing the unique web page.
Redirects in JavaScript
JavaScript is a client-side scripting language.
Establishing redirects in JavaScript is not as Web optimization-friendly as server-side strategies.
The redirects happen solely after the web page begins loading, thereby inflicting a delay. And never all engines like google execute JavaScript or achieve this persistently.
Discover the HTML file of the web page you want to redirect.
Within the <head> part of your HTML file, ideally above “</head>.”
Insert the next script:
<script kind="textual content/javascript">
window.location.substitute("/newpath/");
</script>
Exchange “newpath” together with your desired vacation spot URL. For instance, if you wish to redirect to a web page with the URL https://yourwebsite.com/about-us, you’d substitute /newpath/ with /about-us/.)
Save your modifications to the HTML file. Then take a look at the redirect by accessing the unique web page.
Now that you understand some methods to implement a 307 redirect, when is it needed?
When to Use a 307 Redirect
Website Upkeep
Use a 307 redirect for pages which might be unavailable for a restricted time on account of updates or upkeep. In any other case, guests will see an error message.
Merely take away the redirect as soon as the upkeep is full.
A/B Testing
Suppose you’ve got redesigned your touchdown web page. And also you need to see if it engages your viewers higher than the present model.
For this experiment, you would possibly resolve that for a restricted time, all incoming site visitors to the unique web page ought to be redirected to the brand new design utilizing a 307 redirect.
Throughout this era, all guests will expertise the brand new design.
As soon as your A/B take a look at is over, you may make the brand new design everlasting primarily based on constructive outcomes. Or revert to the unique format if it proves simpler.
Non permanent Content material Relocation
Suppose you’ve got hosted a weeklong on-line occasion with a devoted touchdown web page. After the occasion, you want time to investigate engagement and collect suggestions.
Throughout this interim evaluation section, you do not need guests to entry the occasion web page straight.
You possibly can quickly divert guests to a associated abstract web page utilizing a 307 redirect.
When you’re able to showcase the occasion’s outcomes, highlights, or any post-event content material, you may take away the 307 redirect, permitting guests to entry the up to date occasion web page.
Transitioning Between HTTP and HTTPS
While you safe your web site by shifting from HTTP to HTTPS, you may use the HSTS function.
HSTS tells browsers to all the time use HTTPS as a substitute of HTTP.
If a consumer tries to entry the HTTP model of your website, the browser will mechanically use an inside 307 redirect to take them to the safe HTTPS model.
This ensures an encrypted connection, defending their information.
When To not Use a 307 Redirect
For Everlasting URL Modifications
When you’ve completely moved a web page to a brand new URL, a 307 short-term redirect is not proper.
As an alternative, you need to use a 301 everlasting redirect to sign the change to engines like google.
You need to use Semrush’s Website Audit software to establish pages in your web site with 307 redirects. After which change them to 301 if these pages have been completely moved.
Open the software, enter your area, and click on “Begin Audit.”
As soon as the audit is full, open the “Overview” report and search for the “Crawled Pages” widget. Click on on the variety of “Redirects.”
Overview all of the URLs with a 307 standing code. If any of those pages have been completely moved, implement 301 redirects. Check with our information on organising 301 redirects utilizing an .htaccess file.
It’s also possible to apply an HTTP Standing filter to this report back to see solely pages with a “3xx short-term” standing code.
For Bulk Redirects
When you’re restructuring your complete web site or altering its area, utilizing particular person 307 redirects for every web page may be inefficient and should decelerate your website’s loading time.
From an Web optimization perspective, extreme particular person redirects can confuse search engine crawlers, doubtlessly impacting your website’s rankings.
As an alternative of individually redirecting every web page, it is extra environment friendly to make use of “wildcards” or “pattern-based redirects.”
These shortcuts will let you redirect a number of comparable URLs by way of a single rule.
For instance, you need to use the sample “/weblog/*” to redirect all pages underneath the “/weblog/” listing to a brand new location.
Web optimization Implications of 307 Redirects
Now that you understand when and when to not use a 307 redirect, you must also pay attention to its Web optimization implications. Here is a fast breakdown:
- How hyperlink juice transfers: 307 redirects might quickly go on the unique web page’s Web optimization worth to the redirected one. However as a result of it is a short-term redirect, engines like google anticipate the unique URL to be accessible once more sooner or later. Because of this, the Web optimization worth is not transferred completely.
- How 307 and 302 redirects are handled by engines like google: Each are short-term redirects, and their Web optimization impression is analogous. The important thing distinction is in how they deal with browser requests—not of their switch of Web optimization worth.
When utilizing 307 redirects, make sure to think about their potential impression on Web optimization. Managing them accurately will keep away from errors and assist keep the SERP rankings of your URL.
Finest Practices for 307 Redirects
There’s so much to contemplate when dealing with 307 redirects. Observe these finest practices to make sure optimum outcomes:
Check All Redirects
After organising a 307 redirect, all the time take a look at it to make sure it is working as supposed.
To take action, merely go to the outdated URL and verify whether or not it easily redirects to the specified new location.
Monitor Redirect Efficiency
Repeatedly verify the efficiency of your redirects. You need to use analytics to observe how customers are interacting with redirected pages.
When you discover any anomalies or elevated bounce charges, it is likely to be time to re-evaluate your redirect technique.
Overview and Replace
As your web site evolves, some 307 redirects might not be needed.
Periodically overview your 307 standing code to verify for errors (also known as a “307 error code” when the redirect is not working accurately). And repair them—both by updating or eradicating them.
Restrict Redirect Chains
Keep away from creating chains of redirects (e.g., Web page A redirects to Web page B, which then redirects to Web page C, and so forth).
This may gradual the web page’s loading time and create a poor consumer expertise. Goal for direct, one-step redirects each time potential.
You need to use Semrush’s Website Audit software to establish redirect chains that want fixing. Audit your web site. Then head to the “Points” tab of your report.
You’ll now see all the problems Semrush discovered in your web site. Together with any “redirect chains and loops.”
Overview and repair the problem. Goal to have every hyperlink redirected solely as soon as.
Hold Person Expertise in Thoughts
If a redirect results in a web page that is not related or does not meet the consumer’s expectations, it will probably trigger dissatisfaction.
So all the time think about the consumer’s perspective. Make sure that your redirects result in related, high-quality content material.
Keep away from Frequent URL Modifications
Utilizing 307 redirects often on the identical URL can ship blended alerts to engines like google.
When engines like google detect {that a} specific URL’s vacation spot is often altering, they may turn into unsure in regards to the stability and relevance of that content material.
Because of this, the search engine may not rank the content material extremely.
So use redirects judiciously. And be sure that content material stays constant for optimum search efficiency.
Prioritize Safety
When you’re utilizing redirects as a part of a transition to HTTPS, be sure that all elements of your website are safe. This prevents “blended content material” vulnerabilities.
What do you have to do?
Examine whether or not your website’s exterior assets, plugins, and scripts are appropriate with HTTPS. If not, substitute them.
Doc Your Redirects
Hold monitor of your lively redirects to assist with future troubleshooting and to maintain future web site managers knowledgeable.
The right way to Repair 307 Non permanent Redirect Points
It’s simple to implement a 307 redirect. Nonetheless, you should still face sure points or misconfigurations. Listed here are some widespread options:
Examine Server Configuration
Checking your server configuration helps you guarantee all redirect guidelines are functioning as supposed.
For instance, suppose you wished to arrange a redirect for an outdated product web page to a brand new one. When you mistakenly set the rule to redirect customers to a web page that not exists or to an unrelated part of your website, guests will encounter errors or confusion.
To keep away from such errors, commonly overview the redirect guidelines in your server settings. Be certain they’re pointing to the proper locations. These settings are usually accessible and adjustable in your internet hosting supplier’s management panel.
Overview Server Logs
Analyzing server logs can assist you establish the basis causes of surprising 307 redirects. By analyzing these logs, you may:
- Decide which URLs are often inflicting redirects. This can assist if sure pages are misconfigured or if there’s an error within the redirect guidelines.
- Spot any surprising configurations or modifications which may have triggered the redirect. That is particularly helpful if there’s been a latest replace or if a number of folks have entry to your server settings.
- Acknowledge patterns of consumer conduct or particular occasions resulting in the redirect, resembling type submissions or the accessing of outdated hyperlinks.
As soon as you’ve got recognized the basis causes, you may take the required steps to repair the problems.
Different Fixes
- Make sure that the URLs arrange for redirects are accurately configured. A misconfigured URL in your redirect guidelines can result in surprising conduct.
- In case your web site has caching mechanisms in place, be sure that they aren’t caching outdated redirects. You would possibly have to clear or replace server-side caches.
- When you’re utilizing a CMS or a selected net platform, verify its documentation. Some platforms might need anomalies in how they deal with redirects, or there is likely to be recognized points with sure plugins or configurations inflicting surprising 307 redirects.
- When you’re going through complicated redirect loops, a number of redirects chaining collectively, or different situations that you would be able to’t resolve, think about looking for assist from an online developer or server professional
Use 307 Redirects the Proper Method
Now that you just perceive what a 307 redirect is, the way it works, and easy methods to implement it, let’s get to work.
Audit your web site utilizing a software like Website Audit, and get a full report on all of your redirects.
Overview the URLs with the 307 standing code. And decide:
- Are they accurately used and pointing to the fitting vacation spot?
- Do they want an replace to a unique HTTP standing code?
- Are there any dangerous redirect configurations, like chain redirects?
- Must you take away the redirect?
Primarily based in your evaluation, make modifications accordingly.