301 Redirect Code Generator

List old and new URLs, pick your server or host, and copy redirect rules that send a real HTTP 301 (or 302/307/308) status.

Separate the two URLs with a space, tab, comma or ->. Old URLs are paths on your site; new URLs can be paths or full URLs.

How to create 301 redirects

  1. List each redirect on its own line: the old path, a space, then the new path or full URL. You can paste two columns straight from a spreadsheet.
  2. Choose where your site runs: Apache, Nginx, Netlify, Cloudflare Pages, Vercel, IIS, a PHP app, Express or Next.js.
  3. Pick the status code (301 for most moves) and copy the rules into the file named in the first comment.

A 301 is sent by the server in the HTTP response, before any page is rendered. That is what search engines need to move rankings to the new URL. An HTML <meta http-equiv="refresh"> tag or a JavaScript location.replace() is not a 301: the old page returns 200 first and search engines treat it as a weaker signal.

301, 302, 307 or 308?

CodeMeaningUse it when
301Moved permanentlyA page or site has moved for good (domain change, new URL structure, merged pages). Browsers cache it.
308Permanent, method keptSame as 301 but a POST stays a POST, e.g. for an API endpoint that moved.
302Found (temporary)A short-term move such as a sale page or maintenance; the old URL stays indexed.
307Temporary, method keptA temporary move for form posts or APIs.

Example output

For /old-page /new-page with Apache selected:

Redirect 301 /old-page /new-page

and with Nginx:

location = /old-page {
    return 301 /new-page$is_args$args;
}

Redirect best practices

FAQ

Where do I put the .htaccess rules?

In the .htaccess file in your site's document root, on Apache with AllowOverride enabled. Rules that match query strings need mod_rewrite, which the generator adds automatically. For more Apache settings, see the .htaccess generator.

Does a 301 pass SEO value?

Yes. Google has said 301 and 302 redirects both pass PageRank; the difference is which URL it keeps in the index. Use 301 or 308 for permanent moves so the new URL replaces the old one.

How do I redirect a whole domain?

On Apache, use RewriteCond %{HTTP_HOST} ^old\.com$ [NC] followed by RewriteRule ^(.*)$ https://new.com/$1 [R=301,L]; on Nginx, a server block for the old domain with return 301 https://new.com$request_uri;.