.htaccess file for index page load of homepage

I would like to make an entry in my .htaccess file so that when someone goes to my website the first page that will load will be index.php (as of now index.HTM is loading) I added the entry:

DirectoryIndex index.php but after i upload the file to the server i get the error:

Unknown method DirectoryIndex

the only other line of code that i have on that .htaccess file is

ErrorPage 404 /404.php

so the full .htaccess file looks like this:

ErrorPage 404 /404.php
DirectoryIndex index.php

am i doing something wrong? or is another way to make the server load index.php instead of index.htm?

The server (website) is being hosted by my ISP and they offer to redirect however a redirect is not what I am looking for
LVL 1
James HilloyaAsked:
Who is Participating?
 
aboo_sConnect With a Mentor Commented:
It doesn't make sense that a modified version doesn't support older options, I would suggest you do try my last post.Anyhow, and I'm just guessing here, if the reason u created your index.php is just to run php scripts then you can add a line to your .htaccess that will make php run in html docs:
AddType application/x-httpd-php .php .htm .html
0
 
aboo_sCommented:
If you delete index.html or rename it then by default index.php will be displayed if found!
No need for adjusting .htaccess

That is in APACHI which is the most common server, I beleive other servers act the same as well.
0
 
James HilloyaAuthor Commented:
Thanks for your response but Deleting the index.html access is not an option....i need to keep that file there and also renaming it is not an option nor redirecting it
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
aboo_sCommented:
Why would you want to keep it, if you want index.php to be displayed first !?

Anyway it would be easier to set it so, that in your first visit to index.html it would redirect you to index.php!
0
 
James HilloyaAuthor Commented:
sorry but i cannot say why....i just have to keep it...all i want is to edit the .htaccess file so that the server looks first for index.php
0
 
aboo_sCommented:
ok, try this in your .htaccess :

DirectoryIndex index.php index.html

instead of this:
DirectoryIndex index.php
0
 
James HilloyaAuthor Commented:
should that be line 1 or line 2? or does it matter?
0
 
James HilloyaAuthor Commented:
this is what my htaccess file would look like:

ErrorPage 404 /404.php
DirectoryIndex index.php index.html

is that good?
0
 
James HilloyaAuthor Commented:
tried it and get error: Error parsing access file
0
 
aboo_sCommented:
Please try this instead, and let me know what happens:
ErrorDocument 404 /404.php
DirectoryIndex index.php index.html
0
 
James HilloyaAuthor Commented:
Just spoke with the people that host my website...they say they use a modified version of Apache ...and it does not support changing the order of what index pages loads first...i guess that explains why when i change the htaccess file it does not work....i guess i am out of options...i wish i could delete the index.html page but I can't.....( we use that page for other reasons )...not sure what I can do...in out of options
0
All Courses

From novice to tech pro — start learning today.