On a website I work on, there is a directory with files like this:
abc.com/parts/df/df001/df001.html
There are about 800 in the sequence of df numbers. I’d like to be able to use a link like this:
abc.com/parts/df/df001/
I know you can use defaultIndex to set the default page to something other than index.html, but can you do this for a specific directory, such that for all sub directories of /parts/df map to an HTML file with the same name as the subfolder?
Or, better yet, I’d like to use a URL like this:
abc.com/parts/df001 (even though the file lives at abc.com/parts/df/df001/df001.html)
I think this might be possible with mod_rewrite and regular expressions, but I can’t figure it out.
look at the Apache HTTPD documentation – the directive you’re looking for is called DirectoryIndex. The contexts you can define that are given with
server config, virtual host, directory, .htaccess– but at the same time you learn (from the documentation) that there’s no type of regex supported for that directive. Therefore mod_rewrite is what you need.Regarding the regex – I’d say you can use sth like this:
To be placed either in a .htaccess within parts/df (or any upper folder) or within the vhost configuration. For details on that see the documentation.