URL Friendly Dynamic Pages

aking47

New Member
Messages
13
Reaction score
0
Points
0
Got dynamic content on your website, but the search engines won't crawl it? Don't like the look of the ?page=home ?

OR

Ever changed the template of your site? Is your site set up so that if you want to change anything, you have to edit every individual page?
PHP:
<html>
<!-- Put the top of your template here -->
<?php
  $url = $_SERVER['REQUEST_URI'];
  $url = explode("/",$url);
  $page = $url[count($url)-1];
  if ($page != "index.php") { // You may want to change index.php to the page you're actually using
    include($page); // You can include files from another directory with include("directory/".$page);
  }
  else {
    include("home.php"); // Change home.php to your default page
  }
?>
<!-- Put the bottom of your template here -->
</html>

Put your own content in the same folder as your index.php and reference it like this:
http://www.mydomain.com/index.php/games.php or
http://www.mydomain.com/index.php/my_site.php
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Thanks for this information, but im going to stick with Mod-Rewrite.
 

Pingy

New Member
Messages
46
Reaction score
0
Points
0
I'm really glad you mentioned ModRewrite, Brandon; I've been doing a lot of research on it, but every site that mentioned it tended to use examples that, to me at least, made it seem a lot more difficult than it should be. On my site, I'd like a user's avatar to be posted on their profile; the image is going to be generated dynamically via PHP, with a URL similar to /images/avatar.php?user=#SOME_USER#. I was hoping you might provide some insight regarding which directives I should include in my .htaccess file to get this functionality. Any assistance you provide is, of course, greatly appreciated.
 
Last edited:
Top