I\'ve got a small CMS system written in PHP and running on Apache. The format of the URLs this CMS system uses/generates is:
/display.php?PageID=xxx where xxx is ju
Another way is filter by a dynamic php file with a mapping for pages or a routing strategy like frameworks like drupal code igniter .... and your URL will be like my-pages/about.html -> display.php?PageID=44 my-pages/products.html -> display.php?PageID=34
and so on
Here a suggestion for .htaccess file and the filter the action with this strategy
--- .htaccess file ---- *RewriteEngine on
RewriteRule ^my-pages/(.).html$ MY-URL.php [QSA,L,E]
---------------- MY-URL.php ---------
<?php
$PREFIX = 'my-pages/'; //--- not used
$mapping=array(
'about' => 44,
'products' => 34
);
$pathinfo= pathinfo( $_SERVER['REQUEST_URI'] );
/* $pathinfo['dirname'] -> my-pages
$pathinfo['basename'] -> ???.html
$pathinfo['extension']-> .html
*/
$page = substr( $pathinfo['basename'] ,0,-5);
if( isset( $mapping[$page] ){
// ---- redirect or include
YUOR CODE HERE
}
else {
//--- error 404
YUOR CODE HERE
}
?>
well putting something like
RewriteEngine on
RewriteRule ^about$ ./display.php?PageID=44
RewriteRule ^products$ ./display.php?PageID=34
in your .htaccess
-file shouldn't be the big deal I think...
URL Rewriting for Beginners is my favorite intro article to this, it should cover what you're looking for. In fact, the first actual example where you write a .htaccess
file is almost identical to what you want.