Htaccess changes DirectoryIndex priority to php, not html

  • There is index.html and index.php on the production server
  • By default, index.html is loaded.
  • I want index.php to be loaded by default script, and if index.php is missing, then index.html can be loaded.
  • This is shared hosting, so we do not have access to the httpd.conf file.
  • So, I was thinking of creating a .htaccess file that would fulfill the above condition.

    What is the directive to include in the .htaccess file for this?

In addition, here I explain the reason for the above.

  • The php project runs as part of codeigniter.
  • in the subfolder from the root we have oscommerce.
  • We do not have index.html, and only index.php is present.
  • Periodically, index.html was created by some tools that have iframe code.
  • The client reports this, and we continue to delete the index.html file
  • We also changed the ftp password.
  • so I thought the workaround is for index.php to be loaded as default, not index.html
+7
source share
3 answers

According to the Apache documentation for DirectoryIndex, just put the following in a .htaccess file in the same directory as index.php :

 DirectoryIndex index.php index.html 
+13
source

DirectoryIndex index.php index.html

+3
source

It depends on the configuration of the Apache Directory index. You can customize it according to your needs:

 DirectoryIndex index.html index.shtml index.php index.htm 
0
source

All Articles