To create a url redirect with a simple php script.
1. Go into the directory where you want to place the redirect. (Normally your html folder)
cd /var/www/html
2. Create index.php file
touch index.php
3. Edit the file with whatever text editor you prefer. (I use nano, as i find it easier to use)
nano index.php
4. Use the script below. Of course change the URL to wherever you want it to go.
<?php //* This is this basic code needs for a url redirect * // header( 'Location: http://google.co.uk/' ) ; ?>
Note: that you will have to use the full URL, if you don’tย the redirect will not work
Once you have saved and exited, you will be able to browser to your domain and you will see that you have been redirected to Google UK
The following two tabs change content below.
Keeran Marquis
Network Engineer
Keeran Marquis is a Network Engineer. His main goal is to learn everything within the Networking field, pick up a little bit of scripting, be a poor man sysadmin and share whatever he knows! All Posts are his own views, opinions and experiences, no guarantees they will work for you but point you in the right direction ๐
Latest posts by Keeran Marquis (see all)
- Life and Times of an Unemployed Professional Speed Dater #3 - August 5, 2018
- Life and Times of an Unemployed Professional Speed Dater #2 - August 5, 2018
- Life and Times of an Unemployed Professional Speed Dater #1 - August 5, 2018
I couldn’t resist commenting. Very well written!
Cheers! hope this post helped ๐