Intercept the HTTP request using the 'REQUEST_URI' element of $ _SERVER. This returns (I believe) only the requested page, and not the entire URI / URL - more details here . After you capture the page request, replace the address of the actual file that you need. For example, user-friendly www.somewebsite.com/page01 becomes a request for a more awkward sound www.somewebsite.com?page01.php . This method will not create a virtual directory as such, but should work fine. I used a similar method on my own IT site , where each page is loaded via index.php, allowing this file to keep a log of visitors in real time (the site has a Webalizer that stops for a day or so).
Rewriting the file name may work, although this is not my personal taste. Using PHP to create a URI / URL swap is likely to have the advantage of reducing server demand, because it requires less read / write time on disk than it overwrites the file name.
I hope this helps.
Smartwebguy
source share