CodeIgniter Forums
CI 4 remove index.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: CI 4 remove index.php (/showthread.php?tid=78161)

Pages: 1 2


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.


RE: CI 4 remove index.php - Jalapeno - 02-07-2022

Thank you all! I was about to start a similar subject but thanks to the input of all of you I don't have to. 
"You can also remove it by using .htaccess in the root with index.php by adding this to the .htaccess file."
This turned out to be a perfect solution for me.


RE: CI 4 remove index.php - ClaudeSjDevinHenry - 03-03-2022

i have tried this but not working for me. i have updated config.php not index.php.... also waht do you mean by "try to put it in all htaccess file on your omegle voojio project"


RE: CI 4 remove index.php - Kenn38 - 03-03-2022

(03-03-2022, 04:44 AM)ClaudeSjDevinHenry Wrote: i have tried this but not working for me. i have updated config.php not index.php.... also waht do you mean by "try to put it in all htaccess file on your project"
You create a .htaccess file in your project’s root directory or CodeIgniter directory, then add the following code to the file:

PHP Code:
RewriteEngine On
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ index.php/$[L

Then you open config.php and remove index.php from
PHP Code:
$config['index_page'] = "index.php"