...

View Full Version : index.php?page=



Kix
03-14-2010, 04:49 PM
How would I make my my websites page URLs to be like that instead of being...
index.html, contact.html

I would like it to look cleaner by using PHP. How would I do this? By the way, It would help if you explained the code because im not too good with PHP. Thanks.

Nightfire
03-14-2010, 05:47 PM
// put pages into an array, from eg: page.php?page=index.html
$pages = array("index.html","aboutus.html");

// check to see if page is valid
if(in_array($_GET['page'],$pages)){
// include page requested
include $_GET['page'];
}else{
// page doesn't exist
echo 'page not found';
}

DaiLaughing
03-14-2010, 05:56 PM
I can't see that looks cleaner. Also search engines supposedly look at file names so a good file name can be useful.

masterofollies
03-14-2010, 07:01 PM
This is the way I do it. The following will get you something like index.php?x=shop


if (isset($_GET['x']))
{
$x = explode(':', $_GET['x']);

switch($x[0])
{
case 'shop':
shop();
break;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum