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  Freedom
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
#8

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.
Reply
#9

(This post was last modified: 08-31-2022, 05:22 AM by ClaudeSjDevinHenry.)

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"
Reply
#10

(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" 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB