Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  Web Hosting FAQ  >  Steps to Create a PHP Redirect
Top Scroll

Steps to Create a PHP Redirect

 3 min

You can redirect a URL in several ways. It is beneficial for those looking to redirect requests from their main domain to another directory under that domain. For instance, if you want to direct requests for to, you can do this using an .htaccess file. But, it’s also possible to redirect by using PHP.

In this article, you will learn to create a redirect using PHP.

Does redirecting work with https (SSL certificate)?

The answer is ‘No’. Redirecting is only possible with ‘http’ URLs. In case you install an SSL certificate on ‘’ and visit ‘’, you will be redirected to the ‘Site Not Found’ page.

Steps to Create a Simple Redirect in PHP

Create a file with a name index.php. This can be done by using an FTP client such as Filezilla, or by using SSH. Check the below articles for instructions on how to create it (based on if you’re using an FTP client or SSH):

How to Create and Edit a File via FTP?

How to Create and Edit a File via SSH?

Ensure that the file is in the domain’s directory. This directory is the one that is mentioned while adding the domain to your panel. This can also be confirmed by going to Manage Domains and clicking the Edit button to the right of the domain.

Note: In the above example, the domain is Your domain shows instead while checking your settings page.

In this index.php file, include the below line of code:

<?php header("Location:"); ?>

Don’t forget to change the sample URL to the URL you would like the site to forward.

After this you will get a simple and quick redirection that you can use to easily redirect an HTTP request to any URL.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.