PDA

View Full Version : htaccess: DirectoryIndex vs. Redirect, RedirectMatch


kitchin
10-11-2006, 03:03 PM
In http://www.aota.net/forums/showthread.php?t=17983 about the custom FQ htaccess directive RedirectControl
RedirectMatch is handled earlier in the phase before DirectoryIndex processing is done...
I was going to say that is wrong, but the "is done" clause must make it correct, because Terra must know what he's talking about!

Anyway, using this .htaccess file

Redirect permanent /index.html http://www.example.com/index.php
#
and typing "http://www.example.com/" in the URL bar of my browser gives me this in the URL bar:
http://www.example.com/index.php

I want just:
http://www.example.com/

The same thing happens with RedirectMatch as with Redirect.

It seems whether or not the "DirectoryIndex" processing is "done", it has done something, and that is to change "/" to "index.html" which then gets changed to "index.php". The server-wide DirectoryIndex, that is.

The fix is to use a specific DirectoryIndex to move index.php up in priority. This .htaccess file works:

DirectoryIndex index.php index.shtml index.shtm index.html index.htm index.php4 index.php3 index.cgi index.fquest
# FQ default: index.shtml index.shtm index.html index.htm index.php index.php4 index.php3 index.cgi index.fquest
# Just moving index.php up to first priority.
Redirect permanent /index.html http://www.example.com/index.php
#
The URL stays as:
http://www.example.com

DirectoryIndex also applies to all subdirectories, but I can't think of any time I've had an "index.php" that I did not want to give priority over "index.html", so that seems AOK.

As far as I know, the above is still the default FQ home page priority list, according to the Tutorials (index.shtml index.shtm index.html index.htm index.php index.php4 index.php3 index.cgi index.fquest).

I'm partly posting this so I can search the forums and find the name of that custom directive "RedirectControl" (it's only in the forums), so here are some more keywords: propagate down, index, subfolder, subdirectory.

Another dense coding post.