Redirect Code Generator
Create redirection directives and headers. Generate permanent 301 or temporary 302 rules for Apache, Nginx, Next.js, and web systems.
Parameters
Permanent vs Temporary
โข 301 Redirect: Use when consolidating domains, performing canonical site migrations, or permanently removing routes.
โข 302 Redirect: Use during temporary A/B page testing, product restock updates, or scheduled site maintenance.
Apache (.htaccess)
Redirect 301 /old-path/ https://example.com/new-path/
Nginx rewrite rule
rewrite ^/old\-path/$ https://example.com/new-path/ permanent;
Next.js configuration
module.exports = {
async redirects() {
return [
{
source: '/old-path/',
destination: 'https://example.com/new-path/',
permanent: true,
},
]
},
}HTML Meta redirect
<meta http-equiv="refresh" content="0; url=https://example.com/new-path/">
Javascript route replace
window.location.replace("https://example.com/new-path/");PHP Header snippet
<?php
header("Location: https://example.com/new-path/", true, 301);
exit;
?>IIS web.config rules
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect Rule" stopProcessing="true">
<match url="^old-path/$" />
<action type="Redirect" url="https://example.com/new-path/" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>