About Lesson
How to remove index.php from the URL?
1. Update in the App.php file
We need to change baseURL, indexPage, and uriProtocol variables in the /app/Config/App.php file. You can refer to the below changes.
Then | After |
---|---|
public $baseURL = 'http://localhost:8080'; | public $baseURL = 'http://localhost/your_project/'; |
public $indexPage = 'index.php'; | public $indexPage = ''; |
public $uriProtocol = 'REQUEST_URI'; | public $uriProtocol = 'PATH_INFO'; |
2. Copy index.php and .htaccess files
Copy the index.php and .htaccess files file from the public directory and paste on root your project directory.
3. Update In the index.php
Open the index.php file and change the pathsPath variable.
Then | After |
---|---|
$pathsPath = FCPATH . '../app/Config/Paths.php'; | $pathsPath = FCPATH . 'app/Config/Paths.php'; |