How to set index.php instead of index.html as home page?

melanymaldena

New member
Joined
Mar 4, 2015
Messages
22
Points
0
How do I set the index.php instead of index.html as my home page (so when you go to my site it automatically displays the index.html instead of you having to click on it) or vise versa?
I heard that I need to do that in a config file but I don't know how and where to start. Any one guides me?
 

SenseiSteve

Active member
Joined
Nov 11, 2015
Messages
215
Points
28
I'm confused. What is your end goal here? Is your site created using HTML? Is it a WordPress site?
 

Ron Killian

New member
Joined
Dec 3, 2015
Messages
804
Points
0
Just take out the index.php file or rename it and the web server will automatically run the index.html file. Normal web sever process.

I don't think you can have both. Well, maybe with the htaccess code.

Actually you should be able to have both index.php and index.html, but the index.html will load first by default.
 

Steve32

Active member
Joined
Mar 15, 2014
Messages
210
Points
28
How do I set the index.php instead of index.html as my home page (so when you go to my site it automatically displays the index.html instead of you having to click on it) or vise versa?
I heard that I need to do that in a config file but I don't know how and where to start. Any one guides me?
If you are using Apache on a linux hosting, you need to use DirectoryIndex to set a default page other than index.html or index.php.

It is simple to set the default page for any folders you wanted.

Just logging into your root account and edit httpd.conf

Code:
nano httpd.conf
Find out the line as following
Code:
DirectoryIndex
Change to your requirements, such as
Code:
DirectoryIndex index.html index.htm default.htm index.php index.pl
Save and close the file.

Otherwise, if you are using cPanel, you can more simpler to do this task.

Click on the File Manager icon in your cPanel

Click on the folder you want to set which file is the default, for example public_html

create or add this code to your .htaccess file

#Alternate default index pages
Code:
DirectoryIndex yourcustomfile.html index.htm index.html index.php
Save and recheck on your browsers.


Hope it helps!
 

melanymaldena

New member
Joined
Mar 4, 2015
Messages
22
Points
0
Thanks @steve, it worked!

I could set whatever file I wanted in a folder as default file to run in my hosting.
 

anhbloginc

Member
Joined
Jun 24, 2015
Messages
101
Points
18
From my experience, just remove the index.html, it will automatically recognize index.php :)
 
Newer threads
Replies
1
Views
2,406
Replies
13
Views
8,993
Replies
6
Views
2,908
Replies
0
Views
6,676

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top