Alden Bates (abates) wrote,
Alden Bates
abates

  • Mood:

Useful tip for running a web site on an Apache server

Due to someone linking to a non-existant page on my site, I was trying to redirect /index.php to / earlier. This didn't work. The server went into an infinite loop.

Fine, said I, I'll redirect /index.php to /index.shtml which is the actual file I wanted. But then I discovered that that redirected all accesses to / to /index.shtml which is not what I wanted (I prefer leaving the index page off the end if at all possible, to make for a cleaner URL).

The problem was, it seems, because when you request a directory (e.g. http://www.tetrap.com/drwho/) the web server searches a list of possible file names that your index file could be. Evidently, index.php was earlier on the list than index.shtml.

Sticking this in my .htaccess file fixed it:

DirectoryIndex index.html index.shtml

I guess it'll also speed up accesses to directories marginally, as the server will only be looking for those two filenames.
Subscribe

  • TNG: The Best of Both Worlds, Part I

    The Best of Both Worlds, Part I: The Borg are coming! The Borg are coming! The Enterprise is answering a distress call from a Federation colony.…

  • TNG: Transfigurations

    Transfigurations: A strange alien with the power to heal is rescued by the Enterprise crew. The Enterprise is hanging out in an uncharted star…

  • TNG: Ménage à Troi

    Ménage à Troi: Ferengi kidnap Riker, Troi and Troi's mum. Ferengi and Troi's mother. Oh goody. Riker beats a Ferengi at 3D chess. Data…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments