Posted By

jackkeller on 03/13/09


htaccess apache

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Faux Folders from Files

 / Published in: Apache

This is a little trick I've used a few times to emulate Folders on a site and drop the extensions. In this example I'm using a PHP site but could easily be ported for other file types. One caveat to look out for is files will not always want to be called anymore from their .php and linking to new pages should be done with a href="/newpage" instead of just href="newpage".

Play with it, it's just a down and dirty method to make your urls more sef for sites not running on a cms that has this built into it.

  1. RewriteEngine On
  2. RewriteBase /
  3. RewriteRule ^admin/.*$ - [PT]
  4. # Use the above line for a folder that you DON'T want to follow these rules
  5. RewriteRule ^/?([a-zA-Z0-9-_/]+)/$ $1.php [L]
  6. # Here's where the "magic" happens
  7. # - OLD
  8. # - NEW

Report this snippet  


RSS Icon Subscribe to comments
Posted By: montanaflynn on June 18, 2009

This is just what I have been looking for! Can anyone offer a solution to the PHP linking? I think a 301 redirect would do the job nicely.

Posted By: montanaflynn on June 18, 2009

Actually this never worked out for me, I will continue my search!

Posted By: on January 5, 2019

download best software to android root use app kingo or 360 for pc mac ios windows 10 8 1 7 xp computer forum

You need to login to post a comment.