[thelist] Simulating Folders that Don't Exist

James Hardy evolt at weeb.biz
Wed Jan 26 08:33:06 CST 2005

And lo; it came to pass that the great prophet, Rob Smith spake. And the 
huddled masses rejoiced to hear:
> Is it possible, I'm sure there's a way, to simulate non existant folders in
> URL's? When customer enters something like:

> Possible strategies?
> Rob Smith
Well the easiest way to do this is to create the folders and make their 
default document to be a redirect to the page you actually want.

The nicer and cleaner way of doing this is URL rewriting. With Apache it 
is would be done using mod_rewrite ( 
http://httpd.apache.org/docs/mod/mod_rewrite.html ). If you use IIS then 
you will need to use an add on product such as ISAPI rewrite 
(http://www.isapirewrite.com/ which is what I use on one of the sites I 

Both these methods work in a similar way, you edit a file that tells the 
server what page to serve when a given url is requested. If the request 
is not matched by any in the list, it gets served as normal.

The most powerful feature is that they use regular expressions so that 
you could have

\/Product(.*) mapping to \/cgi-bin\/ProductFinder.pl\?name=$1

which would map /ProductLineA to /cgi-bin/ProductFinder.pl?name=LineA
and /ProductSuperWidget to /cgi-bin/ProductFinder.pl?name=SuperWidget

once you get the hang of it, it is very very handy.


More information about the thelist mailing list