CodeIgniter Default Landing Page

Hi dev,

In CodeIgniter 4, the concept of the default landing page refers to the page that is displayed when a user accesses the root URL of your application. By default, this is the page that visitors see when they first visit your website.

In a fresh CodeIgniter 4 installation, the default landing page is defined in the Routes configuration file.

Here’s how it works:

➡️ Routes Configuration:

In CodeIgniter 4, routing is configured in the app/Config/Routes.php file.

The default route is defined using the $routes->setDefaultController() method.

By default, the route is set to a controller method. For example:


This line tells CodeIgniter to load the index() method of the Home controller by default.

➡️ Home Controller:

The Home controller is usually the default controller in a new CodeIgniter 4 installation.

It is located in the app/Controllers directory and typically contains methods for handling requests related to the homepage or landing page of your application.


namespace App\Controllers;

class Home extends BaseController
    public function index()
        return view("welcome_message");

➡️ index() Method:

The index() method of the Home controller is the default method that is executed when no specific method is specified in the URL.

This method typically loads the view for the homepage or landing page.

return view("welcome_message");

➡️ View for Landing Page:

The view file for the landing page is usually located in the app/Views directory.

This view file contains the HTML, CSS, JavaScript, and any dynamic content to be displayed on the landing page.

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more