A simple htaccess line for microsites

If you’re running a simple site, you may find that using even one sub-directory is overkill. You have one CSS, one JS, and one HTML for the entire site, and name them after your project. If you’re like me, and end up working on multiple sites at a time, it helps if the file names are simple and named after the project. Where that fails is your main “index.html”. I’ve played with redirecting to a project.html file, or having a splash page index.html that redirected. But my solution-de-jour is adding a line to my .htaccess file:

DirectoryIndex my_awesome_project.html

which tells apache to serve my project html when looking for an index file. This is basically a very specific redirect, but you don’t have to serve any possibly sketchy 301 or 302 redirects.

Now I don’t have to guess which of the four “index.html” files I’m working on go to what.

Leave a Reply

Your email address will not be published. Required fields are marked *