Skip to content
AgileLogics

Redirect Generator

Generates a redirect snippet (HTML meta-refresh, JavaScript, or Apache .htaccess) for a destination URL. Output only — no redirect actually happens here.

How it works

Enter a destination URL, choose a method, and click Generate.

Which kind of redirect should you use?

Use a permanent server-side redirect when a URL has moved for good. It sends a 301 or 308 status before any page loads, and Google treats it as a strong signal that the new URL should replace the old one in results. This generator writes that rule for Apache, plus meta refresh and JavaScript fallbacks for hosts where you can't touch server config.

Google's redirects and Google Search page sets the order of preference: server-side first, then meta refresh, then JavaScript, and only if nothing else is possible, a plain link telling people the page moved.

The three snippets it writes

Enter a destination URL, pick a method, and click Generate. For https://example.com/pricing:

Apache .htaccess produces a mod_alias Redirect line with a placeholder source path. Above it, the output adds the comment line # Replace /old-path with the path you are redirecting from. as a reminder, followed by the rule itself:

Redirect 301 /old-path https://example.com/pricing

HTML meta refresh produces a tag for the old page's <head>. The delay slider (0 to 30 seconds) sets the number before the semicolon:

<meta http-equiv="refresh" content="0;url=https://example.com/pricing">

JavaScript produces a script that swaps the current page for the destination:

<script>window.location.replace("https://example.com/pricing");</script>

The delay slider only affects the meta refresh; the JavaScript and .htaccess versions ignore it. In the meta version, &, <, > and " in the URL are converted to HTML entities, so a destination like https://example.com/new-page?ref=a&b=1 becomes …?ref=a&amp;b=1 inside the attribute, which browsers decode back correctly. The JavaScript version wraps the URL as a quoted JavaScript string and writes any < as \u003c, so a URL containing </script> can't close the script tag early; the browser still sees the original character. The .htaccess version percent-encodes any character that isn't allowed in a URL, so https://example.com/my page becomes https://example.com/my%20page and spaces, quotes or non-ASCII letters can't split the directive into extra arguments. Existing %XX escapes are left alone, and the URL decoder turns an encoded target back into readable text if you want to double-check it. Because Apache's Redirect only accepts an absolute URL or a path on the same server, the .htaccess method shows an error unless the destination starts with a scheme such as https:// or with /.

Permanent or temporary: what the status codes mean

The .htaccess snippet always uses 301. That's right for most moves, but here is how the main codes differ under RFC 9110 and in Google's handling:

Code Meaning May a browser switch POST to GET? Google uses it as a canonical signal?
301 Moved Permanently Moved for good Yes, for historical reasons Yes
308 Permanent Redirect Moved for good No, method must be kept Yes
302 Found Temporarily elsewhere Yes, for historical reasons No
307 Temporary Redirect Temporarily elsewhere No, method must be kept No

For ordinary page moves the method question doesn't matter, since search engines and visitors arrive with GET. It matters for form endpoints and APIs: if a POST endpoint moves, use 308 (or 307) so the request body isn't dropped. Apache's Redirect accepts other numeric 3xx codes in place of 301, as well as the keywords permanent, temp and seeother.

Installing the .htaccess rule

  1. Copy the output and replace /old-path with the old URL's path (you can delete the comment line, or keep it; Apache ignores lines starting with #), without the domain. It must start with / and is case-sensitive.
  2. Open (or create) the .htaccess file in the site's document root. The directive needs mod_alias, which is part of standard Apache builds, and an AllowOverride setting that permits FileInfo directives.
  3. Paste the line and save.
  4. Request the old URL and confirm you get a single 301 straight to the destination. The redirect checker shows every hop.

Mind the prefix matching described in the mod_alias documentation. Redirect 301 /blog https://example.com/articles also sends /blog/2024/post to https://example.com/articles/2024/post, because the remainder of the path is appended. It matches whole path segments, so /blogroll is left alone. When you need to rewrite only one exact URL, or change the structure of the remaining path, use RedirectMatch with an anchored regular expression.

Pitfalls that cost rankings or visitors

Chains. Google's site move guide advises redirecting straight to the final destination and keeping chains short. When you move a page twice, update the first redirect to point at the newest URL.

Removing redirects too soon. The same guide says to keep redirects for as long as possible, generally at least a year, and suggests keeping them indefinitely for users' sake.

Timed meta refreshes. A delay above 0 is read by Google as temporary, and W3C's accessibility technique F41 lists timed refreshes as a failure unless users can turn off or adjust the timing. Use a delay only for a deliberate "this page has moved" notice.

JavaScript-only redirects. location.replace() removes the old page from the tab's history, so the back button doesn't bounce people into a loop, which is why the tool uses it. But Google only sees the redirect if rendering succeeds, so treat it as the fallback of last resort.

After a redirect goes live, make sure the destination's own canonical tag points to itself with the canonical URL checker.

Last updated

Frequently asked questions

Which redirect type is best for SEO?
A permanent server-side redirect (301 or 308) whenever you can set one up. Google's redirect documentation ranks server-side redirects first, then meta refresh, then JavaScript as a last resort, because a JavaScript redirect is only seen if Google manages to render the page.
Does Google treat a meta refresh like a 301?
Only when the delay is zero. Google interprets an instant meta refresh as a permanent redirect and a delayed one as temporary. Leave the delay slider at 0 if the old URL is gone for good.
Why does the .htaccess output say /old-path?
It's a placeholder, and the output says so in a comment line above the rule. The tool only asks for the destination, so you must replace /old-path with the path being redirected, starting with a slash, such as /2019/spring-sale. Apache treats it as a prefix, so anything after that path is carried over to the destination.
Does this tool redirect anything itself?
No. It only prints a snippet for you to copy into your server config or page. No request is made to the destination URL, and nothing is sent to our server.
How do I do the same redirect on nginx?
The tool doesn't produce nginx syntax, but it's one line. Inside the matching location block write return 301 followed by the destination URL and a semicolon. Use 302 instead of 301 for a temporary move.