Log in

View Full Version : URL rewriting



sukanya.paul
04-02-2008, 05:03 AM
hi,

can any1 help me with the method of rewriting url. i have a site which i have to redo in php. there is 1500 pages in the original site.
So i was wondering if i could make my work easier by url rewriting, but am not sure how to go about it.

appreciate your help..Suk

Nile
04-02-2008, 11:44 AM
Well, I don't know what you mean, I think you mean something like this at the end for your url:

site.com/?p=home
But theres also mod rewrite that'll turn the above to:

site.com/p/home
So, search mod rewrite.
You can aslo make example#1 like this:


if($_GET['page'] == "home"){
echo "Home";
}

The you go to:

site.com/?page=home
Then if you don't really wanna make a million of these ifstatements then you can use switch.


switch($_GET['page']){
case 'home':
echo 'Home';
case 'contact':
echo 'Contact!';
default:
echo 'Home!';
}

For more info on the switch() function, go to http://us.php.net/switch

tfit
04-03-2008, 03:47 PM
If you use an apache webserver using rewriterule is easier