CodeIgniter Forums
CI 4 remove index.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forum-9.html)
+--- Thread: CI 4 remove index.php (/thread-78161.html)



CI 4 remove index.php - nurgaleevarman - 12-07-2020

Why is there no normal instruction for removing index.php from url for apache 2? The instruction in the documentation does not work.
How step by step remove index.php? Or maybe better to remove index.php in default configuration?


app/Config/App.php
-----------------
public $indexPage = '';


RE: CI 4 remove index.php - captain-sensible - 12-07-2020

i've got apache 2.4 runnig on slackware -current and no problem getting rid of index.php in url.

From memory getting rid of index.php in url was quite prominent in docs , i can't quickly find it but its in docs somewhere
app/config/App.php
Code:
/*
    |--------------------------------------------------------------------------
    | Index File
    |--------------------------------------------------------------------------
    |
    | Typically this will be your index.php file, unless you've renamed it to
    | something else. If you are using mod_rewrite to remove the page set this
    | variable so that it is blank.
    |
    */
    public $indexPage = '';



RE: CI 4 remove index.php - demyr - 12-08-2020

You can try the steps here : Stackoverflow

The answer says:

Step 1: In public/ directory, copy index.php and .htaccess to your root project directory.
Step 2: In the root project directory, open index.php and edit the following line:
   
             index.php -> $pathsPath = FCPATH . '../app/Config/Paths.php';
to
            index.php => $pathsPath = FCPATH . 'app/Config/Paths.php';


RE: CI 4 remove index.php - paliz - 12-08-2020

In modern web application we have a backend mvc and front end mvc so you dont need to remove index all you need mvc front end frame work like angular. Js or vue. Js react. Js


RE: CI 4 remove index.php - nurgaleevarman - 12-28-2020

(12-08-2020, 02:16 AM)demyr Wrote: You can try the steps here : Stackoverflow

The answer says:

Step 1: In public/ directory, copy index.php and .htaccess to your root project directory.
Step 2: In the root project directory, open index.php and edit the following line:
   
             index.php -> $pathsPath = FCPATH . '../app/Config/Paths.php';
to
            index.php => $pathsPath = FCPATH . 'app/Config/Paths.php';
I think this is not the correct way to delete an index.php by modifying the distribution.


RE: CI 4 remove index.php - InsiteFX - 12-29-2020

You can also remove it by using .htaccess in the root with index.php by adding this
to the .htaccess file.

Code:
       # Remove index.php from URL
       RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
       RewriteCond %{THE_REQUEST}              ^[^/]*/index\.php [NC]
       RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]



RE: CI 4 remove index.php - thinkstartpl - 01-26-2021

Thank you, for sharing this information, You can also remove it by using .htaccess file.