18

I am currently setting up a website from a client on his hosting account. The website address and for some reason doesn't default to .php files (that is: index.php). If I put index.php and there is no index.html file I receive the following error:

If you feel you have reached this page in error, please contact the web site owner: someemail@example.com If you are the web site owner, it is possible you have reached this page because: The IP address has changed. There has been a server misconfiguration. The site may have been moved to a different server. If you are the owner of this website and were not expecting to see this page, please contact your hosting provider.

His hosting is a shared hosting on cpanel.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
perpetual_dream
  • 1,046
  • 5
  • 18
  • 51

4 Answers4

31

Use the DirectoryIndex directive in your .htaccess file

DirectoryIndex index.php
Ulrich Palha
  • 9,411
  • 3
  • 25
  • 31
4

The problem was caused by my web-browser cache, as soon as I have cleared my cache it worked!

perpetual_dream
  • 1,046
  • 5
  • 18
  • 51
3

You can set your default page as the directory index using .htaccess file in 2 ways.

First method

DirectoryIndex yourfile.php

Above code will set 'yourfile.php' as the directory index. But this will applies to all sub folders as well and may occur '404' error for some related urls.

Second method

Use this code to set your handler file for the root directory

RewriteEngine on
RewriteRule ^$ /yourfile.php [L]

If you want to set a handler file for the sub folder, use this one

RewriteEngine on
RewriteRule ^subfolder/$ /yourfile.php [L]
Nikz
  • 1,346
  • 1
  • 18
  • 24
2

Try

DirectoryIndex index.php

if that doesn't work you might have to work around it by providing index.html like

<html><frameset rows="*"><frame src="index.php"></frameset></html>

(ofcourse more elaborate)

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • 3
    If you already suggest a solution of that sort, frame usage is absolutely useless: just set redirect with corresponding `` tag. – Dmitry Ginzburg Sep 25 '16 at 08:48