Developer ToolsFree Tool

PHP redirection

Provided byRapidTablesrapidtables.com

PHP redirection

Screenshot of PHP redirection on RapidTables
rapidtables.comOpen the live tool →
About this tool

What PHP redirection does

RapidTables' PHP redirection tool helps users generate PHP code snippets for implementing HTTP redirects quickly and easily. By inputting a source URL and selecting a destination, the tool constructs the necessary server-side logic using standard PHP functions, providing multiple methods including header-based and conditional checks. The output gives developers accurate syntax to integrate into web applications for managing traffic flow programmatically, assisting with both permanent moves (301) and temporary redirections. The generated code can be directly copied and pasted into PHP files to redirect visitors from one URL to another.

Step by step

How to use the RapidTables PHP redirection

  1. 1

    Open the PHP redirection page on RapidTables

  2. 2

    Enter the source URL in the provided input field

  3. 3

    Enter the destination URL where you want visitors to be sent

  4. 4

    Select the desired HTTP response status code (e.g., 301 for permanent redirect)

  5. 5

    Copy the generated PHP code snippet and paste it into your PHP file

Is it right for you

Best for

Developers and website administrators who need to implement PHP redirects quickly without manually writing header functions, especially when setting up permanent (301) or temporary redirects across various scenarios.

Limitations

  • Generated code requires a .php file extension to function properly
  • HTML files need additional .htaccess configuration to process PHP code
  • No unit switching or alternative redirect methods beyond PHP header functions
Questions

PHP redirection FAQ

What HTTP status code should I use for a permanent URL move?
Use 301 Moved Permanently for permanent redirects, which transfers page rank from the old URL to the new URL in search engine indexes.
Can I redirect from an HTML file using this PHP tool?
PHP redirection from HTML files usually will not work unless the server is configured to process PHP in .htm or .html extensions via .htaccess or httpd.conf.
Do I need to include exit() after the header function?
Yes, the generated code includes exit() after the header() call to ensure no further PHP code executes after the redirect.
Can this tool generate redirects for both permanent and temporary moves?
The tool provides PHP code for implementing HTTP redirects with selectable status codes, supporting both permanent (301) and temporary (302) redirection scenarios.