301 Redirect Online Logo

PHP 301 redirect generator

If You have no access to the server and .htaccess file, here is the bulk pure PHP  301 redirect generator to make the fastest possible redirects in this situation. It generates "header location" rules for the exact page to page redirection based on simple "if" conditions and some regular expressions syntax.  Please, read notes at the bottom. 

Paste lines with Old and New urls here:

Copy PHP header location rules from here:

Separator between old and new url in a line:

Add old query strings to new urls:

Query strings exact match policy:

How to use?

Copy and paste columns of old and new urls, for example from Google docs or Excel, into first field. Push "Generate" button. Copy PHP header 301 redirect code into your application. Learn more about  usage of PHP header function for 301 and other redirects here.

What is PHP header 301 redirect?

PHP header 301 redirect is programming language side redirect and it uses header() PHP function to make permanent redirects. It is possible to make PHP side redirects in any place of your code. To earn the best speed better to place your redirects at the beginning of the first PHP file of your application. If you have no .htaccess file in your server configuration or .htaccess file is not accessible, PHP 301 redirect may help a lot.

When to use?

If you need fast 301 redirects, but can't access your server, you may use pure PHP header function to do 301 page redirection. It is still good for SEO and other purposes.

Where should I place the code?

The faster the better. So the earlier the better. Place your PHP header 301 code at the begging of the enter point php file of your application. In many cases, it can be index.php file.

How should I place the code?

Many CMS systems like WordPress can rewrite enter point file on update. So, create some file, for example 301-redirects.php, and place your PHP header 301 redirect code in it. Include this file in your enter point file. For example, add such a line at the beginning: include '301-redirects.php';