What index (php or html) loads when both are present?

3

I would like to know which index file loads in case you have an index.html and an index.php on the site.

Let's say that I'm building a PHP site, but I need the server for tests and so on, so I make a simple HTML page and put it there ... So there were two indexes (one html and another php). What would be loaded when someone entered the site?

    
asked by anonymous 23.01.2017 / 17:33

2 answers

-1

I just did not get the informed way and the page always loads PHP first: ... So I put a code at the top of my PHP that checks if I passed (in the url) a 'true' value for the variable 'testing' and, if YES, it loads my PHP, otherwise (if I do not pass anything) it redirects to my index.html. Here's the code below for who else needs something like this: P

<?php
if($_GET['testing'] != 'true'){ ?>
	<html>
		<head>
			<meta http-equiv="refresh" content="0; url=http://example.com/index.html" />
		</head>
	</html>
<?php } else {
	/* aqui o código PHP */
} ?>

That way, it loads my HTML if I enter the URL example.com , but if I enter example.com/?testing=true it loads my PHP.

Thanks for the support! :)

    
24.01.2017 / 14:01
7

In the case of an APACHE server, you determine the order by the DirectoryIndex directive on your httpd.conf :

DirectoryIndex index.php index.phtml index.html index.htm

You can also make this setting on your vhosts individually for each domain!

This order defines which extensions the server will look for first, in the absence of one, it fetches the next one from the list.

    
23.01.2017 / 17:39