We help IT Professionals succeed at work.

Understanding URLs when only a path is passed

WestCoast_BC asked
Can someone please explain to me what is done to support a URL with just a pathname passed. For example, sometimes I see URLs that look something like:
and the website knows to display products.

My site is written using coldfusion.

How is this done? Is there a sub directory called products which has an index.cfm page?
Watch Question

Dr. KlahnPrincipal Software Engineer
The details depend on the web server in use, but let's take Apache for an example.

Apache gets a URL of http://www.mysite.com/somewhere

Is there a file named "somewhere" under the site root directory?  a) Yes?  Serve it up.  b) No?  Then next look at the policy defined by the DirectoryIndex directive.

(see https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex)

Is there a policy?  1) No?  Then use the default policy.  Is there an "index.html" in the "somewhere directory?  a) Yes?  Serve it up then.  b) No? Give the requester a 404.

2) There is a DirectoryIndex policy for naked URLs?  What does it say to do?  It says "index.html index.shtml index.cgi"?  Then ...

Is there an "index.html" in the "somewhere" directory?  Yes?  Serve it up.  If not, continue.

Is there an "index.shtml" in the "somewhere" directory?  Yes?  Serve it up.  If not, continue.

Is there an "index.cgi" in the "somewhere" directory?  Yes?  Serve it up.  If not, serve up a big helping of 404.

It gets more complicated than this, especially if there are .htaccess files in use; and it can be much, much more complicated if mod_rewrite is in use, but this is the basic behavior.
ZvonkoSystems architect
Top Expert 2006


On ColdFusion server you need index.cfm in that directory and the script in index.cfm does show the Products presentation.

ZvonkoSystems architect
Top Expert 2006


That das say that this three URLs are do the same on ColdFusion application server:




That is because index.cfm ist the default page when no page is given in the URL path.


Thank you. If I understand correctly I will have to create a directory and with an index.cfm file for each of these URLs that I would like to support.

I do have a .htaccess file in use. Is there something that I can add that if it encounters this type of URL it can change it to something like: mysite.com/index.cfm?d=products

I see this type of URL used quite a bit and I would like to support this if it is not too hard. I would rather not have to create a directory and index.cfm for each one that I want to support.
ZvonkoSystems architect
Top Expert 2006


You started this Question that you want to understand something.

That part was answered more then enough by   Dr. Klahn

Because you use ColdFusion as Application Server you have more possibilities then explained by the Expert.

But for that you realy need to know what you need and how to get it.

On ColdFusion Aplication Server you have an Administration Dashboard where you can also do Mappinings from Logical paths to directories outside and inside of your web root.

And if you do NOT use the ColdFusion built-in Web Server but some other frontend web server, Apachee, IIS, then you have the possibilties described in the first answer.

I would not recommand doing any of the .htacces of CF Administrations Mapping in the production until you get good feeling how it works.

Additionaly keep in mind that changing   .htaccess and application mappings, on two ends  the configuration always results in ConFusion  :  )


Good luck,


Systems architect
Top Expert 2006

One more thought about redirect.

You do not redirect only that URLs that you have in mind but every request, also other resources then .cfm pages, e.g. image URLs.

Therefore it is better readable to create the folders as I proposed and place the index.cfm in every subfolder.

Then you can include in every such index.cfm one central include file where you place one for all processing, if that is what you want.

 Here the link to cfinclude: