Overview
Enter a source path and a destination URL and get a ready-to-use HTTP 301 (permanent redirect) snippet for Apache (.htaccess), Nginx, or PHP - the three most common places a server-side redirect actually needs to be written by hand. The Apache snippet uses the simple `Redirect` directive rather than a `RewriteRule`, since a single exact-path redirect doesn't need mod_rewrite's pattern-matching complexity. The Nginx snippet uses an exact-match `location =` block with a `return 301`, the idiomatic way to redirect one specific path without the regex engine mod_rewrite users often reach for out of habit. The PHP snippet uses `header("Location: ...", true, 301)` followed by `exit`, which is the correct way to issue a real HTTP 301 from application code without letting execution continue afterward. This tool deliberately does not generate a client-side redirect (a `<meta http-equiv="refresh">` tag or a JavaScript `window.location` assignment) as an alternative option, because those are a fundamentally different mechanism - they run after the page has already loaded in the browser, are invisible to search engines and other automated clients as an actual HTTP status code, and mislabeling one as a "301" would be actively misleading. Source paths and destination URLs are validated and safely interpolated into each snippet - the PHP output specifically escapes quote and backslash characters so a crafted destination URL can't break out of the generated string literal. Useful for migrating a page to a new URL, consolidating duplicate content, or fixing a broken link without needing to look up each server's exact redirect syntax from scratch. Runs entirely client-side - nothing is sent anywhere.
Best for: Migrating a page to a new URL or fixing a broken link without looking up each server's exact redirect syntax
How to use this tool
- Enter the source path. The old path being redirected from, e.g. /old-page.
- Enter the destination URL. The full URL to redirect to, e.g. https://example.com/new-page.
- Pick a platform. Apache, Nginx, or PHP - each has its own correct 301 syntax.
- Copy the snippet. Paste it directly into your .htaccess file, Nginx server block, or PHP script.
Why use this tool
Real HTTP 301s only
No meta-refresh or JavaScript redirect option that could be mistaken for a genuine server-side permanent redirect.
Idiomatic syntax per platform
Simple Redirect directive for Apache and an exact-match location block for Nginx - not needlessly complex RewriteRule/regex patterns for a single exact path.
Safe interpolation
Inputs are validated and the PHP snippet escapes quotes and backslashes so a crafted URL can't break out of the generated string.
Three platforms, one tool
Covers the three most common places a server-side redirect actually needs to be hand-written.
Frequently asked questions
Those are client-side redirects - they only happen after a browser has already fully loaded the old page, and search engines and other automated HTTP clients don't see them as a real 301 status code at all. Labeling one as a "301 redirect" would be inaccurate and could mislead an SEO migration into thinking search engines will treat it as a proper permanent redirect, when they won't.
For a single exact-path redirect, the plain `Redirect` directive (from mod_alias) does exactly the same job as a `RewriteRule` (from mod_rewrite) with far less syntax and no regex to get wrong. RewriteRule earns its complexity when you need pattern matching, conditions, or multiple related rules - not for one fixed path.
Inputs are validated (a source path must start with "/" and neither field may contain whitespace) before being interpolated into any snippet, and the PHP snippet specifically escapes quote and backslash characters so a crafted destination URL can't break out of the generated string literal.