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

  • Hi Livejournal

    Long time, no write. I hope everyone is keeping safe from the pandemic and not going out much. I started working from home earlier this week when…

  • Wait

    What happened to my friends page? Clearly I have been away from LJ too long and they have changed things. Look, I'm a big subscriber to the idea…

  • I've been playing Fallout 3 a bunch recently

    I'm playing it as an evil character because I already did a good playthrough. Reminds me of someone...

  • 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