Make index.html default, but allow index.php to be visited if typed in
By default, the DirectoryIndex is set to:
DirectoryIndex index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml mwindex.phtml
Apache will look for each of the above files, in order, and serve the first one it finds when a visitor requests just a directory. If the webserver finds no files in the current directory that match names in the DirectoryIndex directive, then a directory listing will be displayed to the browser, showing all files in the current directory.
The order should be DirectoryIndex index.html index.php
// default is index.html
Reference: Here.
default to index.html but allow user to type to index.php and get the php page
Use this in your .htaccess
file to redirect the user to index.html
when he types the domain name, if he especially types index.php
, he will be able to get on that page
RewriteRule ^$ index.html [R=301,L]
how to make default page home.php instead of index.html and index.php
You just need home.php
in your DirectoryIndex
to make it works. Remember that this is using in .htaccess file of your root project:
DirectoryIndex home.php
Run index.html file before index.php file on browser
Easiest way: rename index.php
to index2.php
and link to it from index.html
.
index.php not loading by default
Apache needs to be configured to recognize index.php as an index file.
The simplest way to accomplish this..
Create a .htaccess file in your web root.
Add the line...
DirectoryIndex index.php
Here is a resource regarding the matter...
http://www.twsc.biz/twsc_hosting_htaccess.php
Edit: I'm assuming apache is configured to allow .htaccess files. If it isn't, you'll have to modify the setting in apache's configuration file (httpd.conf)
Giving index.html priority over index.php
It depends on your server configuration for now, some .htaccess file you may not have access too. You can define/overrule this in your own htaccess using, for example :
DirectoryIndex index.html index.php
the priority depends on the order you set the filenames in that line
Why does index.html have priority over index.php?
It really depends on the Server you're using. This is a matter of configuration. It's not that there's any advantage from using html vs php filetype.
You could say that the .html
variation takes precedence due to the fact that it's the most basic web format.
If you're using Apache, just check the default .htaccess
setup:
DirectoryIndex index.html index.shtml index.php index.htm default.html Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php3 index.phtml home.htm home.html home.shtml index.wml
You can edit that and make it fit your needs.
Related Topics
Preserve Line Breaks in Textarea
Centering an Image Within a Div
Force Youtube Embed to Start in 720P
How to Create a Frosted Glass Effect Using CSS
Can Outlook 2010 Use a Web Font in an HTML Email
HTML + CSS: Numbered List with Numbers Inside of Circles
How to Make The Web Page Height to Fit Screen Height
CSS Prevent Div Flex from Stretching Child
How to Overlap Two Images Using CSS Style
Anchor <A> Tags Not Working in Chrome When Using #
<Strong> VS. Font-Weight:Bold & <Em> VS. Font-Style:Italic
Writing HTML Form Data to a Txt File Without The Use of a Webserver
Make Input Type="Password" Use Number Pad on Mobile Devices