I’m using bootstrap to make a website and I noticed my php index overrides my html index. Is the php code supposed to refer part of the html code to display?
For example, I have a nice little text message that says “hey” in html. Then some random php password checker script I found online.
Nothing in my page says “hey“, it’s as if the php is the html. I’m new so maybe I’m just tripping.
Sorry if it is hard to understand.
2
Answers
It sounds like you have two
index
pages:index.html
andindex.php
.The PHP page will take precedence due to the DirectoryIndex directive of Apache:
You can change this to pick
.html
files by default if you would like (by swapping the order so thatindex.html
comes first), though there is no real need, as you can still write HTML from within the PHP file:index.php
:Both approaches are valid, and both will allow you to output HTML from a PHP file.
Are you using an Apache server? If so, there is a directive in there that tells it what to do when you reference a folder and not a file. It will list the file types in order of priority. For example:
DirectoryIndex index.php index.html
Swap
index.php
andindex.html
around and the HTML will take priority.You can find the directive in your Apache config file usually called httpd.conf or apache.conf.
Alternatively, to make sure the correct file is called, just reference it explicitly in your browser eg:
localhost/index.html
.