[Solved] DirectoryIndex

MikeDVB

Well-Known Member
#1
I'm not sure exactly what is going on with this so I'm going to lay it all out.

The default server directory index is:

/usr/local/apache/conf/httpd.conf
Code:
DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html
This would mean that it would load index.htm before index.html and either of these before PHP.

The user put in their public_html (cPanel server) this DirectoryIndex:
/home/user/public_html/.htaccess
Code:
DirectoryIndex index.php index.htm index.html
In a sub-directory of the public_html folder for some reason the server is loading index.html instead of index.htm (when both exist) and in the .htaccess with the same folder is:
/home/user/public_html/subdirectory/.htaccess
Code:
DirectoryIndex index.htm index.html index.php
All of these DirectoryIndex directives would say to load the index.htm before index.html but it's simply not doing so. I did check for mod_rewrite rules and any other sorts of redirects that would cause this odd behavior to no avail.

Essentially instead of loading /home/user/public_html/subdirectory/index.htm it's loading /home/user/public_html/subdirectory/index.html

Code:
root@server [/home/user/public_html/subdirectory]# ls -lh | grep index
-rw-r--r--  1 user user 2.5K Sep 27 22:29 index.htm
-rw-r--r--  1 user user 8.8K Nov 24 01:40 index.html
-rw-r--r--  1 user user  738 Feb  7  2010 index.php
All of these DirectoryIndex directives would say to load the index.htm before index.html but it's simply not doing so. I did check for mod_rewrite rules and any other sorts of redirects that would cause this odd behavior to no avail.

This next part leads me to believe it's a mod_rewrite, but there are no mod_rewrite rules (and I even moved the .htaccess to .htaccess.bak for every one in the account to make sure) and it still does this... Now it looks to me like it's ignoring the DirectoryIndex directive and loading the index.php (which is then redirecting to the index.html) but again, it should be loading the index.htm and not touching index.php.
Code:
root@server [/home/user/public_html/subdirectory]# curl -I http://thesite.com/subdirectory/
HTTP/1.1 301 Moved Permanently
Date: Fri, 10 Dec 2010 21:37:41 GMT
Server: LiteSpeed
Connection: close
X-Powered-By: PHP/5.2.14
Location: index.html
Content-Type: text/html
Vary: User-Agent
This is on LSWS 4.0.17, and I did even rebuild the httpd.conf and do a hard restart on lsws (service lsws stop && service lsws start).

I'm really quite stumped.

Edit: Not sure how I did a double-thread... This is the one I want to keep "alive" :)
 
Last edited by a moderator:

MikeDVB

Well-Known Member
#3
Please try changing the order in
/home/user/public_html/.htaccess

that's the only place where index.php is in front.
I will do so, but isn't the .htaccess in the closest directory supposed to be the one that governs that directory? The issue is that the client specifically wants the index.php to load first in that directory, but not in the subdirectory.
 

MikeDVB

Well-Known Member
#4
That change did in fact cause the .htm to load instead of the .php but I would consider this abnormal or a bug as from my understanding the .htaccess in the directory with the files, or in closest relation to the files is the one that is supposed to govern the directive.

Going back to the fact that the client wants the index.php to load as the index in public_html and they want the index.htm to load as the index in public_html/subdirectory, what do you advise? Is this a quick fix?
 

mistwang

LiteSpeed Staff
#5
can you double check that it is correctly configured under subdirectory? spell, .htaccess file name, etc.
If it is, we may have to try to reproduce it in our lab.
Is the subdirectory document root of a subdomain?
 

MikeDVB

Well-Known Member
#6
can you double check that it is correctly configured under subdirectory? spell, .htaccess file name, etc.
If it is, we may have to try to reproduce it in our lab.
Is the subdirectory document root of a subdomain?
It's the document root of an add-on domain. I'm more than happy to provide you access to see it all for yourself. Drop me a PM if you want that information.
 
Top