301 & 302 Redirect Generator

Use this simple tool to redirect your old URL to a new URL using htaccess, PHP, HTML, JavaScript, ASP or ASP.Net

Old URL:

New URL:

Select redirection type:

Use the generated code to redirect your URL

Create a file called .htaccess in the doc root (web / httpdocs / www folder).

Copy the code below and save it in .htaccess file to redirect {{oldUrl}} to {{newUrl}}

Open the {{oldUrl}} HTML file and paste the below code before the </head> tag to redirect {{oldUrl}} to {{newUrl}}

In the {{oldUrl}} PHP file, put Location:{{newUrl}} in the header() function. Below is how the code should look like

In the {{oldUrl}} PHP file, copy the entire code below and remove all other code in that file (important) to redirect {{oldUrl}} to {{newUrl}}.

<meta http-equiv="refresh" content="0;url={{newUrl}}">
<script type="text/javascript">
window.location.replace("{{newUrl}}");
</script>
<?php
header("Location: {{newUrl}}", true, 301);
exit();
?>
<?php
header("Location: {{newUrl}}");
exit();
?>
<%@ Language="VBScript" %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "{{newUrl}}"
Response.End
%>
<script language="C#" runate="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","{{newUrl}}");
Response.End();
}
</script>
Redirect 301 {{oldUrl | onlypath}} {{newUrl}}
Redirect 302 {{oldUrl | onlypath}} {{newUrl}}

Tip:
After you've implemented the redirection, use our redirect checker tool to make sure the redirection is working properly.

Q&A

How can I use this tool to do a 301/302 redirect?

After you've selected which redirection you'd like to implement, simply enter the old URL and the new URL it should be redirected to. Pick the redirection type and click on generate. This tool will give you the exact code you need to copy and also gives you clear instructions on how and where to implement this code snippet.

How can I do 301/302 in Wordpress, Magento, Drupal or Joomla?

Each of these CMS's have an extention that helps you manage and implement redirections. Visit the links below to see how it is done:

How can I create a 301/302 redirect in Namecheap, GoDaddy or Hostgator?

If you want to redirect your URL from your hosting service itself, you can set the redirection directly from your host's cPanel. Click on one of the links above for more details:

How many 301 redirects are too many?

The answer to this question is simply no - there is no limit on how many 301 redirects a page can have. As Matt Cutts from Google discusses in his video regarding 301 limites on websites it is perfectly fine to permanently move a root-page with 1000s of subpages using 1000s of 301 directs to the new subpages and Google will process all of them without any limitations. However there is a limit of how many 301 rdirects you can chain together, so it's always best to use a direct redirect to the new location without unnecessary detours.

Are 301 redirects bad for seo?

A permanent redirect requests the search engines to entirely remove the old URL from their index and to update all page related values like page rank, traffic value, page authority and MozRank. Although their might be some loses, it's save to say that a 301 redirect will pass 97% of the link juice to the new URL. So out of an SEO perspective 301 redirect is the best option to move an entire site with all it's ranks and content to a new URL without losing much of it's search engine visibility.

When should I use a 302 redirect?

A 302 redirect is a good option for any situation where a temporary redirection is necessary, but you want to bring your traffic back to your original URL afterwards. Imagine your blog got hacked and you need to point your visitors to your main landing page for a couple of hours while fixing the blog - in such a case you will want to implement a 302 redirect. Keep in mind that such a temporary redirection will not pass any link juice or page values to the new URL, so setting a temporary redirect for too long can hurt your page visibility.

What is the difference between 301 and 302 redirects?

The main contrast between 301 and 302 redirects is that the first one redirects a page permanently, wherein a 302 moves a page temporarily to a new location. This means a permanent 301 redirect tells a search engine or user agent that the old URL doesn't exist anymore and it requests them to update their database and to replace the old URL with the new one - including all page related ranks and values. A 302 redirect lets the search engine know that the page is temporary unavailable and will continue to use this URL when it is back, so no updates will be made.

How long for 301 redirect to take effect?

The redirection itself will be in place immidiately after it's implemenation. So let's say you moved mypage.com/a.html to mypage.com/b.html the moment you're trying to visit /a.html it will redirect you to the new URL. The important question however is how long does it take for the new page to show in the search results. Unfortunately there is no clear answer to this and it really depends on the search engine itself and the amount of pages you are moving. Let's say you move only one site to a new location, it will take approximately a week for this page to show up in Google under it's new URL. Bing and Yahoo will take longer for this. If you are migrating a huge property with 1000s of pages it can take months for all new pages to be indexed and show properly in the search engines.

Why are there no 301 JavaScript or HTML redirects?

Permanent 301 redirects are handled and executed by the server. That means 301 redirections can only be implemented from the server side and not via any client (browser) side languages like JavaScript and HTML. However if you're not using any server side languages like PHP, ASP or ASP.Net you can still easily implement a permanent redirectons using the cPanel of your host, an extentions of your CMS or via .htaccess itself.