Publishing System Settings Logout Login Register
Simple PHP Custom Redirection
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on June 19th, 2008
5558 views
PHP Coding
[MY_P2L_AD]
Hey guys,

I wanted to post this simple tutorial on how to make simple redirection without mysql. With .htaccess you can make the url more simpler so it look more SEO. Let's Start, It won't take long! Approx. time: 1 min.

First create a file named redirect.php;


in redirect.php

<?php
/**** Open PHP Tag then identify your variables**/

$aff=$_GET['n'];

/***  URL will be in this format http://yoursite.com/redirect.php?n=p2l  so we GET n from URL**/


/***  let say my url is  http://yoursite.com/redirect.php?n=myfriend  it will redirect to http://myfriendsite.com**/


if($aff=="myfriend") {

 header('Location: http://myfriendsite.com');

}

elseif($aff=="google") {

 header('Location: http://www.google.com');

}


else {

 header('Location: http://mysite.com');

}


/***  you  can do 100000's of elseif **/


/***  close PHP**/

?>


open notepad and name a new file ".htaccess"

in .htaccess;  EDITED ==> This only code will direct all of your tags!



RewriteEngine On


RewriteRule ^go/([0-9a-z]*)/?$ /redirect.php?n=$1 [NC,L]





Now the coding part is done. WITH the .htaccess you can redirect in this format  http://mysite.com/go/google will redirect you to google or if your server don't support .htaccess your url will be like this: http://mysite.com/redirect.php?n=google will do the same thing.


It's not that hard, Probably The Simplest tutorial there!!
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
AFG89

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top