Get online today — Domain + Hosting at discounted prices View Combo Offers ›

301 Redirect Generator

Generate exact 301 redirect code for Apache, Nginx, and PHP.

Use this tool to instantly generate the exact code required to implement a proper HTTP 301 Permanent Redirect on your web server. Simply enter the old URL and the new destination URL, and the tool will output the correct syntax for Apache (.htaccess), Nginx, and raw PHP.

Setting up 301 redirects is the single most important technical SEO task when migrating a website, changing domain names, or deleting old blog posts. A proper 301 redirect tells search engines (like Google) that the page has moved permanently, ensuring that all of your hard-earned SEO link juice is transferred to the new page.

How it works

There are multiple ways to redirect a user, but only a 301 Permanent Redirect is respected by search engines for transferring SEO value. A 302 Temporary Redirect or a JavaScript/Meta-refresh redirect will often cause Google to drop the old page from the index without passing any authority to the new page.

Apache (.htaccess): This is the most common method for shared hosting and WordPress sites. The tool utilizes the mod_alias module (the Redirect 301 directive) which is significantly faster and less prone to regex errors than using mod_rewrite.

Nginx: If you run a high-performance VPS or dedicated server using Nginx, you cannot use `.htaccess` files. You must place the generated rewrite or return directive directly inside your Nginx server block configuration.

PHP: If you don't have access to your server's configuration files (or if you need to perform conditional logic before redirecting), you can paste the generated PHP header() code at the very top of your PHP script, before any HTML is rendered.

Frequently asked questions

What happens if I don't use a 301 redirect?

If you change a URL or delete a page without setting up a redirect, any user (or search engine crawler) clicking an old link will hit a 404 Not Found error. Google will eventually de-index the old page, and you will lose 100% of the SEO value and traffic that page had accumulated.

Can I redirect an entire domain to a new domain?

Yes. Instead of entering a specific page path (like `/old-page.html`), you can set up a global wildcard redirect in Apache or Nginx that automatically maps every single page on `old-domain.com` to its exact counterpart on `new-domain.com`.

Will a 301 redirect slow down my website?

Server-level redirects (Apache and Nginx) are incredibly fast and execute in microseconds. However, chaining multiple redirects together (e.g., Page A -> Page B -> Page C) forces the browser to make multiple round-trip network requests, which will significantly slow down the user experience. Always redirect directly to the final destination.

Why does the PHP redirect code have an exit() statement?

In PHP, sending a redirect header does not automatically stop the script from executing. If you forget to include `exit;` immediately after the `header()` call, the server will continue processing the rest of the page, which wastes CPU resources and can lead to severe security vulnerabilities.

Related tools

Need hosting that just works?

Free SSL, daily backups and 24×7 support on every Loudhost plan.

View Hosting Plans