How to Redirect a Page Using PHP

By J M Whitaker, Inc

Rate: (0 Ratings)

Whether you've made changes to your site's directories or you just want to make it easier for a user to reach a page with a long URL, you can easily redirect your visitors to a different site using just a small snippet of PHP code...

Instructions

Difficulty: Easy

Things You’ll Need:

  • A Text Editor
  • Access To Edit Your Site's Files
Step1
First, determine the URL to the new page your visitors will be redirected TO. This should be the full URL that shows up in the web browser when you visit the page.
Step2
Edit the file that the visitors will be redirected FROM. If the users will need to be redirected from your main domain or a specific directory (example, mywebsite dot com/store) then be sure to edit the index file in that directory.

The attached picture for this step shows the code that should be inserted into this file. Be sure to replace the URL with the new one we determined in step one.
Step3
Load the redirect file into the directory on your web server where the users will be visiting. Test the new file in all major web browsers. The redirect should be instantaneous so if the file just "hangs" or does nothing at all, make sure that there is no other code in the file.

Tips & Warnings

  • Be sure that your text/HTML editor does not had the HTML tag to your file automatically. This will cause the redirect to fail.
  • If the redirect is a permanent one, be sure to note the change of URL somewhere on the new page so that users can update their links, favorites and/or bookmarks.

Resources

Post a Comment

POST A COMMENT

Request a New How-To Article

Looking for more How To information? Chances are there’s an eHow member who knows how to do what you’re looking to do. Submit an article request now!

eHow Article: How to Redirect a Page Using PHP

Article By: J M Whitaker, Inc

J M  Whitaker, Inc

Authority Authority | 3690 Points

Category: Computers

Articles: See my other articles

Related Ads