301 Redirect Code Generator
Enter the old URL and the new destination, pick your redirect type and server platform, and get the ready-to-paste redirect code.
Last updated: May 26, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is 301 Redirect Code Generator?
A redirect tells browsers and search engines that a URL has moved. The HTTP status code signals whether the move is permanent (301, 308) or temporary (302, 307), and search engines transfer link equity accordingly.
The implementation differs by platform: Apache uses the `Redirect` directive in `.htaccess`, Nginx uses `return` or `rewrite`, IIS uses a `<rewrite>` rule in `web.config`, PHP uses `header('Location: ...')`, and client-side redirects use the meta refresh tag or JavaScript. This tool generates the correct snippet for each platform.
How to Use 301 Redirect Code Generator
Enter the old path (e.g. /old-page) in "From URL".
Enter the full new URL in "To URL".
Choose the redirect type (301 for permanent SEO-friendly moves).
Choose the server/platform you're using.
Copy the generated code and paste it into the appropriate config file.
Common Use Cases
- Redirecting old blog post URLs after a site redesign.
- Setting up 301 redirects when migrating to a new domain.
- Creating temporary 302 redirects for A/B testing.
- Generating server-specific redirect syntax without memorizing the format.
- Building redirect rules for Apache, Nginx, or IIS configurations.
Example Input and Output
A permanent 301 redirect from /old-page to /new-page in Apache .htaccess.
From: /old-page → To: https://example.com/new-page (301, Apache)# Add to your .htaccess file
Redirect 301 /old-page https://example.com/new-pagePrivacy
All code generation happens in your browser. No URLs are sent to a server.
Nginx rewrite vs return
The generated Nginx code shows both a location block with return and an equivalent rewrite. The return directive is simpler and recommended; the rewrite is shown as an alternative if you already have a rewrite context.

