Contact Anything Graphic today! Subscribe via RSS
August 31, 2010

Redirect To Any Page With PHP

PHP is so awesome for many reasons because it allows you to do just about anything regarding how your website interacts within itself. Here is an extremely easy and short tutorial on how you can seamlessly redirect a user to another page with PHP. It doesn't even have to be within your own site!

 

A reason you may want to do this is because that page/folder no longer exists. Another reason may be that you don't have the time (like me right now) to design a custom 404 error page in WordPress. I just redesigned my whole website from the ground up and left the 404 error page out as my time is super limited right now. This was the perfect use for a PHP script like this until I am able to complete that page. However, I may just stick with this handy bit of code for a while.

 

Here's How
  1. Everytime you have to delete a large chunk of code or significantly change a file, back it up.
  2. Delete everything (all code) from the file. By all code, I mean everything in the file.
  3. Copy and paste the following PHP code into your file:

 


<?php

   header('Location: http://www.anythinggraphic.net') ;

?>

Make sure to replace my website with your URL. That's it!

Kevin Donnigan
Kevin Donnigan

My name is Kevin Donnigan, freelancing under the name Anything Graphic. I am uber passionate about graphic, logo, and website design and utilizing key concepts to visually communicate. I also specialize in XHTML development, CSS stylin’, and Search Engine Optimization tactics for your web presence.

Got something to say?