0

ive seen things like

<?php
 if(is_array($_GET)) { 
    $page = isset($_GET['p'])?strtolower(urlencode($_GET['p'])):'index.php'; 
    $page = preg_replace('/[^A-Za-z0-9]/','',$page); 
//  echo '['.$page.']'; 
} 
else $page = ''; 
if(!file_exists($page.'.php')) require("index.php"); 
else require(_path_.$page.'.php'); 

} ?>

But i dont really get how this works entirely.

Basically I want to do something with php and htaccess i believe i will know, example; domain.com/page/about would go to domain.com/pages/about.php and output the contents? i know ive seen this somewhere but i forget what its called! I've been searching forever now!

Im not the best at code and need a bit help to do, please.

1 Answers1

0

I think what you're looking for is mod_rewrite. See Apache's documentation for a comprehensive explanation. Tuts+ also has a nice tutorial.

You essentially want to get the the page as a token and pass that to this script as a GET parameter, which your script will evaluate.

If you don't need the full functionality of mod_rewrite and you're just looking to drop the PHP extension, then this question is more relevant: .htaccess; no extension required

Community
  • 1
  • 1
Kyle
  • 2,727
  • 2
  • 17
  • 23