pavlos1982 Posted May 16, 2009 Share Posted May 16, 2009 hello my name is paul and i have a small personal website www.maheseychelles.co.uk which i have turn into php but the only problem is that my url is http://seychelles.hostosaur.com/?pg=home but i want it to be http://seychelles.hostosaur.com/home or www.maheseychelles.co.uk/home instead, and this is my content management code i used <?php if (isset($_GET['pg']) && $_GET['pg'] != "") { $pg = $_GET['pg']; if (file_exists('pages/'.$pg.'.php')) { @include ('pages/'.$pg.'.php'); } elseif (!file_exists('pages/'.$pg.'.php')) { echo 'Page you are requesting doesn´t exist'; } } else { @include ('pages/home.php'); } ?> im just wondering what do i change to make it into the url i want with my page name infront of my domain name, thanks in advanced Quote Link to comment Share on other sites More sharing options...
gregor171 Posted May 16, 2009 Share Posted May 16, 2009 This seems logical question. SEO! The simplest way (for novice and also for a few pages portal) to do this is to simply make folders with index.php files inside. You fill some variable with $page_content and include root file. Sample code for /people_culture/index.php <?php $page_content = 'people_culture'; include_once '../index.php'; ?> Sample code for index.php // first you should test if u have variable already if(!isset($page_content)) $page_content ='home'; But for advanced users, this is done with apache url rewrite rule that maps everything to index.php. Than you need some mapper code to show the right content. Mapper is stored either in mysql or in php. Quote Link to comment Share on other sites More sharing options...
pavlos1982 Posted May 16, 2009 Author Share Posted May 16, 2009 thank you very much for the quick reply i tried it did nt work i think maybe im doing something wrong im very new to php , if its posible if i send you one of my page of my website then you can see the codes and see where im going wrong if i can see one example working then ill probably can do the rest ??? if yes please send me your email address or msn or yahoo , thank you for your help i appreciate it Quote Link to comment Share on other sites More sharing options...
jkewlo Posted May 16, 2009 Share Posted May 16, 2009 well the rewrite he is taling about is a .htaccess rewrite look into that but be careful. as for the other option <?php $page = $_GET['page']; if($page == "your_page"){ inlcude("you_page.php"); ?> that is very simple page=your_page would be in the url it self site.com/index.php?page=your_page it would then look from the if statement and grab the your_page.php and include it into your site where ever you have your content displayed. You could also do this <?php $page = $_GET['page']; if($page == "your_page"){ //some code here // some more code ?> that would then display your code. for example I just did this for my search engine <center><a href="search.php?p=Item">Item Search</a> | <a href="search.php?p=Monster">Monster Search</a> <br /> <?php $p = $_GET['p']; if($p == 'Item'){ echo "Item Database search Engine <FORM NAME=Articlessearch ACTION=search.php?p=Item METHOD=POST> <INPUT TYPE=TEXT NAME=searchString> <INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=search> </FORM> "; $Limit = 2; $searchString = $_POST["searchString"]; $searchString = stripslashes($searchString); If($searchString == "") $searchString=$_GET["searchString"]; If($searchString == "") { exit(); } $page=$_GET["page"]; //Get the page number to show If($page == "") $page=1; //If no page number is set, the default page is 1 $searchResult=mysql_query("SELECT * FROM item_db WHERE name_japanese LIKE '%$searchString%' ORDER BY id") or die(mysql_error()); $NumberOfResults=mysql_num_rows($searchResult); $NumberOfPages=ceil($NumberOfResults/$Limit); $searchResult=mysql_query("SELECT * FROM item_db WHERE name_japanese LIKE '%$searchString%' ORDER BY id LIMIT " . ($page-1)*$Limit . ",$Limit") or die(mysql_error()); While($row = mysql_fetch_object($searchResult)) { echo "<table width=200 border=0 cellpadding=0 cellspacing=0> <!--DWLayoutTable--> <tr> <td width=390 height=185><table border = 1 cellspacing=0 cellpadding=3 width = '200px'> <tr class = 'lmd'> <td class = 'bborder' align = 'left' colspan=10> <b> ". $row->name_japanese ." </b> Item ID# ". $row->ID ." (". $row->name_japanese .")</td> </tr><tr> <th class='lmd' align='left' width=105>Type</th> <td class='bb' align='right' width=100>N/A</td> <th class='lmd' align='left' width=70>Class</th> <td class = 'bb' align='right' width=105>n/a</td> <th class='lmd' align='left' width=70>Buy</th> <td class = 'bb' align='right' width=50>". $row->price_buy ."</td> <th class='lmd' align='left' width=70>Sell</th> <td class = 'bb' align='right' width=50>". $row->price_sell ."</td> <th class='lmd' align='left' width=70>Weight</th> <td class = 'bb' align='right' width=30>". $row->weight ."</td> </tr><tr><th class='lmd' align='left' valign='top'>Description</th> </td><td colspan=9 class='bb' valign='top'>N/A</td></tr> <tr><th class='lmd' align='left'>Item Script</th><td colspan=9 class='bb'>". $row->script ."</td></tr> <tr><th class='lmd' align='left'>Dropped By</th><td colspan=9 class='bb'>N/A</td></tr> <tr><th class='lmd' align='left'>Buyable At</th><td colspan=9 class='bb'>N/A</td></tr><tr><th class='lmd' align='left'>Obtained from</th><td colspan=9 class='bb'>N/A</td></tr> </table></td> </tr> </table> <BR>"; } $Nav=""; If($page > 1) { $Nav .= " <A HREF=\"search.php?p=Item&page=" . ($page-1) . "&searchString=" .urlencode($searchString) . "\"> << Prev </A>"; } For($i = 1 ; $i <= $NumberOfPages ; $i++) { If($i == $page) { $Nav .= "<B>[$i]</B>"; }Else{ $Nav .= " <A HREF=\"search.php?p=Item&page=" . $i . "&searchString=" .urlencode($searchString) . "\">[$i] </A>"; } } If($page < $NumberOfPages) { $Nav .= " <A HREF=\"search.php?p=Item&page=" . ($page+1) . "&searchString=" .urlencode($searchString) . "\"> Next >></A>"; } Echo "<BR><BR>" . $Nav; } ?> I hope that this can give you some guide. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.