How to change default index page in php

The server looks for specifically named files as the first page of your website, also known as the index page. The default order of index file names our particular servers look through is index.htm, index.html, index.php, and finally default.htm. You can change the name of the index file your account looks for by altering the .htaccess file. Perhaps you want to have a specific custom name for your index file or maybe you are migrating from another host and the index page is named differently. This way your internal links will not be broken by renaming the index file.

Don’t have time to read the article on how to change your default index page in .htaccess? Watch our walk-through video.

What is an htaccess File?

The .htaccess file is a hidden text file within your hosting account that can be very powerful. It is designed so that you can modify it to change the behavior of your website that normally would take higher access beyond your account. It acts as a liaison between your domain and the server and can perform many functions.
Learn more about htaccess

Changing your Default Index File via htaccess

  1. Log into your cPanel.
  2. Find the Files category and click on the File Manager icon.
    How to change default index page in php
  3. Click Settings at the top right corner.
    How to change default index page in php
  4. Select the document root for the domain you are working with and be sure the checkbox next to Show Hidden Files is checked. Click the Save button.
    How to change default index page in php
  5. Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option.
    How to change default index page in php
  6. You may be presented with a popup. Click on the Edit button.
    How to change default index page in php
  7. You are now in the htaccess editor. Paste the following code at the top of the page to configure your desired index page. In our example below, we decided to make the index page of our folders named first.html.
    #Alternate default index page
    DirectoryIndex first.html

    You can also list more than one file in the configuration. The file will be read left to right and check for them in that order. In this example, we add index.htm, index.html, and index.php to the list. First the server will check for first.html, if it does not find a file with that name, it continues to index.htm and so on.

    #Alternate default index pages
    DirectoryIndex first.html index.htm index.html index.php
  8. Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration.

I have website http://mywebsite.com If I hit this URL it take index.php and index.html as default page. How can I make home.php as default page. I have tried this but not working by placing following code inside .htaccess file of public_html

DirectoryIndex home.php index.html index.php

asked Apr 3, 2013 at 5:00

How to change default index page in php

0

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

answered Apr 3, 2013 at 5:04

How to change default index page in php

EliEli

14.7k5 gold badges57 silver badges77 bronze badges

2

You need AllowOverride +Indexes in your httpd.conf to be able to use DirectoryIndex in .htaccess.

Barring that, the absolutely easiest way to redirect (without the root access to Apache config and modules) is putting this as index.html:



  
    
  
  
  

answered Apr 3, 2013 at 5:05

AmadanAmadan

183k23 gold badges224 silver badges284 bronze badges

2

DirectoryIndex directive applies to all subfolders, if you want set diffrent files for each directories, you can use mod-rewrite.

To set /file.html as root directory handler, you can use this at the top of your htaccess :

RewriteEngine on
RewriteRule ^$ /file.html [L]

To set a diffrent file as index for a subfolder, use this :

RewriteEngine on
RewriteRule ^subfolder/$ /myfile.html [L]

answered Mar 7, 2017 at 17:14

How to change default index page in php

Amit VermaAmit Verma

39.9k19 gold badges87 silver badges109 bronze badges

Just try to rewrite /index.html and /index.php into /home.php

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/index\.(html|php)
RewriteRule ^(.*) /home.php

answered Apr 3, 2013 at 5:17

0

How do I change my default Web page?

You can tell Chrome to open to any webpage..
On your computer, open Chrome..
At the top right, click More. Settings..
Under "On startup," select Open a specific page or set of pages. Click Add a new page. Enter the web address and click Add. Click Use current pages..

How do I change the default index page in htaccess?

Changing your Default Index File via htaccess.
Log into your cPanel..
Find the Files category and click on the File Manager icon..
Click Settings at the top right corner..
Select the document root for the domain you are working with and be sure the checkbox next to Show Hidden Files is checked. ... .
Look for the ..

How can I change the default start page html?

default..
Log in to cPanel..
Navigate to the Files section, then click on the File Manager icon..
Navigate to your public_html and go inside the folder where you find the default. ... .
Create a New File. ... .
Name the new file index. ... .
Whatever you put inside the index..

How do I change the default page in cPanel?

How to Use a Custom Default Page.
Login to cPanel..
Click the File Manager button under Files..
In the left navigation window, click the cpanel3-skel folder, then click the public_html folder..
Click the Upload button, then click the Browse button and select your custom default page, and click the Open button..