Link to home
Create AccountLog in
Avatar of John Grosshans
John GrosshansFlag for United States of America

asked on

Have web server load index.html instead of index.php as default

I have a webserver set up using CentOS and Apache
I need the webserver to load index.html as the default instead of index.php.

The httpd.conf file has "DirectoryIndex index.html index.html.var index.php"
I have a .htaccess file in my html directory with this as the first line "DirectoryIndex index.html index.htm index.php"

I've got another .htaccess file in the subfolder that I actually need the change in with this as the first line "DirectoryIndex index.html index.htm index.php"

What am I missing? Why won't it load index.html instead of index.php
Avatar of kuzmanovicb
Flag of Serbia image

First try to edit Your .htaccess file to "DirectoryIndex index.html" and if that doesn't help try to edit  httpd.conf like that.

Best Regards
Avatar of John Grosshans


hey @kuzmanovicb
both htaccess files now have DirectoryIndex index.html as the first thing
and the httpd.conf file has DirectoryIndex index.html and it is still loading .php first
I also ran "sudo /etc/init.d/httpd restard" and I got no change
with "DirectoryIndex index.html index.html.var index.php" index.php should be loaded only if index.html and index.html.var does not exist.
Can you try without index.php, edit to be like this: "DirectoryIndex index.html" and tell me what happens
That is what I tried in my last comment and it is still pulling php

the .htaccess file next to the index files has this
DirectoryIndex index.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

while the one in the root has

DirectoryIndex index.html

# BEGIN WordPress

# END WordPress

RewriteEngine on

#if the site is placed in the root folder of the domain,
#the following line should be: RewriteBase /
#it also may be unnecessary - this depends on the server configuration
#example set /revou/ if setup url is, set / if setup url is

RewriteBase /twit/

##please DO NOT edit these lines:

RewriteRule ^(css|js|grafika|sample_photos|avatars25|avatars_mini|resources|ajax|colourmod|rss|backgrounds|bglib|adminlogin|vision|post_img|logo|db_backup) - [L]
RewriteRule ^api\/ - [L]
RewriteRule ^(logout.php|randompic.php|sticker_data.php|my_status.php|sticker.swf|delete_me.php|get_sms.php) - [L]

#RewriteRule ^.*$ index.php

RewriteRule ^[^/].*$ index.php

you see anything in there?
Avatar of kuzmanovicb
Flag of Serbia image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
alright, something is up cause both .htaccess files are set to
"DirectoryIndex index.html"

and that is it and it still isn't working.

Should I try restarting my whole server not just apache?
Or is there something else going on
Avatar of arnold
DirectoryIndex as others pointed out is only one way to direct apache to determine which file will be loaded when one is not specified.
One would need to see the entire config to see what and where the direction is to load the index.php.
I was working off a VPS from a company that is sinking. They take terrible care of their servers and once I switched to a different company I never had this problem again.