Welcome Guest, Not a member yet? Register   Sign In
CI 4 remove index.php
#1

(This post was last modified: 12-07-2020, 01:59 AM by nurgaleevarman.)

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 = '';
Reply
#2

(This post was last modified: 12-07-2020, 01:29 PM by captain-sensible.)

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 = '';
Reply
#3

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';
Reply
#4

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
Enlightenment is key factor to discover new world
Reply
#5

(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.
Reply
#6

(This post was last modified: 12-29-2020, 12:30 PM by InsiteFX.)

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]
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB