Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Apache serve index.php instead of index.html?

If I put the following line in a index.html file, to make Apache include the index.php file:

  <?php include("/Live/ls_client/index.php"); ?>     

visiting the index.html page shows me this:

<!--?php include("/Live/ls_client/index.php"); ?--> 

Why is that? Why doesn't it actually include the PHP file?

like image 845
Adam Wojda Avatar asked Apr 24 '13 12:04

Adam Wojda


People also ask

How do I change the index html file in Apache?

Apache file path/conf/httpd.confChange index. html or index. php to whatever default page you want. Restart Apache ~ Done.


1 Answers

As others have noted, most likely you don't have .html set up to handle php code.

Having said that, if all you're doing is using index.html to include index.php, your question should probably be 'how do I use index.php as index document?

In which case, for Apache (httpd.conf), search for DirectoryIndex and replace the line with this (will only work if you have dir_module enabled, but that's default on most installs):

DirectoryIndex index.php 

If you use other directory indexes, list them in order of preference i.e.

DirectoryIndex index.php index.phtml index.html index.htm 
like image 54
Glitch Desire Avatar answered Sep 23 '22 17:09

Glitch Desire