Developer Tools · URL Redirect · Free

301 Redirect Code Generator

Move a page without losing your search-engine rank. Enter the old page URL and the new page URL, pick the redirect type your host supports — PHP, ASP, ASP.NET, Apache .htaccess, HTML meta tag, or JavaScript — and press Generate. The ready-to-paste snippet is built in this browser tab; nothing is uploaded anywhere.

Redirect geneartor

Click on code to copy text to replace old URL page file with redirection code.

Where to put redirect code

Where to put the redirect code depending on whether the domain name or hosting server changed
DomainnameHostingserverRedirect code placement
not changednot changedold page on same server
not changedchangedold page on new server
changednot changedold page on same server
changedchangedold page on old server

* Only with .htaccess redirect: add redirect code to httpd.conf file or to .htaccess file.

Redirect options

Redirect type comparison: redirect side, old page file type, old URL server type, permanent 301 support
Redirect typeRedirect sideOld page file typeOld URL server typeIs permanent 301 redirect?
PHPServer-side.phpApache / Linuxyes
ASPServer-side.aspIIS / Windowsyes
ASP.NETServer-side.aspxIIS / Windowsyes
Apache .htaccessServer-sideallApache / Linuxyes
IIS web.configServer-sideallIIS / Windowsyes
HTML meta tagClient-side.htmlallno
JavascriptClient-side.htmlallno
jQueryClient-side.htmlallno

301 Redirect Code Generator — Use permanent 301 redirect to preserve search engines rank. The code generator supports web pages redirection of html, php, asp, aspx files and .htaccess redirect.Enter the old and new page URLs, pick a redirect type and press Generate; the snippet is built entirely in this browser tab and nothing is uploaded to a server.

STEP 1

Enter both URLs

Type the URL of the old page you want to replace and the URL of the new page that should take over. Example URLs are pre-filled — replace them with your own, and both must be valid http or https addresses.

STEP 2

Pick the redirect type

Match the type to where the old page lives: .php pages use PHP redirect, .asp and .aspx pages use ASP or ASP.NET on IIS/Windows, Apache/Linux sites can use the .htaccess rule for any file type, and a plain .html page can fall back to an HTML meta tag or JavaScript redirect.

STEP 3

Generate and copy

Press Generate, then click the code (or press Copy) to put the snippet on your clipboard. Replace the old page’s file with the generated code — or paste the RewriteRule into your .htaccess / httpd.conf — and visitors and search-engine crawls are sent to the new URL.

How 301 redirects work

Why a permanent 301 redirect?
A 301 tells browsers and search engines that the old address has moved for good, so the old page’s ranking signals are passed to the new URL instead of the old page turning into a 404.
Server-side or client-side — what’s the difference?
PHP, ASP, ASP.NET, Apache .htaccess, and IIS web.config redirects are server-side and answer with a real 301 status on any server that supports them. HTML meta tag and JavaScript redirects are client-side: the old page still loads first, they do not send a 301 status, and they work on any server but only for .html pages.
Where do I put the redirect code?
If the domain name and hosting server are unchanged, the code goes into the old page on the same server. If the hosting server changed but the domain did not, put it on the new server’s old page location. If the domain name changed, the code stays on the old server so the old URLs keep forwarding. Only with an .htaccess redirect can you instead add the rule to the httpd.conf or .htaccess file.
Which type fits my hosting?
Apache / Linux hosts: PHP or the Apache .htaccess rule. IIS / Windows hosts: ASP (.asp), ASP.NET (.aspx), or the IIS web.config option listed in the options table. Any other host serving plain .html: the HTML meta tag or JavaScript fallback — remember it is not a true 301.
Do my URLs leave the browser?
No. The snippet is a plain string assembled locally by this page from the two URLs and the type you picked — there is no upload, no account, and no request to any server.

Privacy: redirect snippets are generated entirely in this browser tab from the two URLs you typed. Nothing is sent to a server, and no account or permission is required.