CodeIgniter Forums
remove index.php from url - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: remove index.php from url (/showthread.php?tid=70179)

Pages: 1 2


remove index.php from url - jyoti sudyal - 03-05-2018

How  can i remove index.php from url


RE: remove index.php from url - my_RZ - 03-05-2018

(03-05-2018, 04:59 AM)jyoti sudyal Wrote: How  can i remove index.php from url

https://www.codeigniter.com/user_guide/general/urls.html#removing-the-index-php-file


RE: remove index.php from url - jyoti sudyal - 03-05-2018

"https://www.codeigniter.com/user_guide/g...x-php-file"
i have tried this already but its not working at my end.


RE: remove index.php from url - ciadmin - 03-05-2018

The thread was started in the CI2 subforum, suggesting that the answer might be in https://www.codeigniter.com/userguide2/general/urls.html


RE: remove index.php from url - jyoti sudyal - 03-05-2018

As i mentioned above i have tried this already but this is not working for me.


.htaccess file ::

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


config file ::
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';


RE: remove index.php from url - Muthusamy - 03-05-2018

If your Apache server has mod_rewrite enabled, you can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the “negative” method in which everything is redirected except the specified items:


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

Same situation happens to me. I have change the code in htaccess file.
Please check with this. Hope it will work for you also.

If it is not work check Please let us know your url is a Https or Http.


RE: remove index.php from url - jyoti sudyal - 03-06-2018

mod_rewrite is enabled by default on godaddy's server and my url is http.


RE: remove index.php from url - isoftzone - 01-07-2021

1. Create a .htaccess file:

You need to create a .htaccess file in the project’s root directory or CodeIgniter directory. Creating a .htaccess file will allow us to modify our rewrite rules without accessing server configuration files. Because of this reason, .htaccess is critical to our web application’s security thus ensures that the file is hidden. htaccess is an acronym used for Hypertext Access, it is a configuration file that controls the directory “.htaccess”.

After creating the .htaccess file, add the following code to this file.
RewriteEngine On-
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2. Removing index.php file

Open the config.php file in your text editor and remove index.php from here.

Change:

1
$config['index_page'] = "index.php";
To:

1
$config['index_page'] = '';
But in a few cases, it may happen that the default setting for url_protocol does not work properly. For solving this problem we need to open config.php and

Change:

1
$config['uri_protocol'] = "AUTO";
To:

1
$config['uri_protocol'] = "REQUEST_URI";
Most of the time it is already set to REQUEST_URI, In that case, we don’t need to change it.

3. Enable apache mode rewrite

Now, we will need to activate the mod_rewrite with the help of the following command.

1
$ sudo a2enmod rewrite


4. Restart Apache

Now we need to restart the Apache, to do so we write the following command.

1
$ sudo service apache2 restart
This will activate the module or alert us that the module is already in effect.
Regards
I-Softzone- Web Design Company


RE: remove index.php from url - adminweb10 - 03-22-2025

Code:
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
    RewriteEngine On
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>



RE: remove index.php from url - gosocial2 - 03-24-2025

Set line 43 of app/Config/App.php to

public string $indexPage = ''; // = 'index.php';