Remove index.php from URL Using By .htaccess in CodeIgniter


These will help you to remove index.php from URL in Codeigniter Using .htaccess


Steps To Remove index.php using .htaccess:-





Step:-1  Open the file config.php located in application/config path.  Find and Replace the below code in config.php  file.

//  Find the below code

$config['index_page'] = "index.php"

//  Remove index.php

$config['index_page'] = ""


Step:-2  Go to your CodeIgniter folder and create .htaccess  file.


 Path:

Your_website_folder/
application/
assets/
system/
user_guide/
.htaccess <--------- this file
index.php
license.txt


Step:-3  Write below code in .htaccess file

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


OR 

/* This is for keep in the image and robots from index.php */

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L] …..

now correct it like this :

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]


Step:-4  In some cases the default setting for uri_protocol does not work properly. To solve this issue just open the file config.php located in application/config and then find and replace the code as:

//  Find the below code

$config['uri_protocol'] = "AUTO"

//  Replace it as

$config['uri_protocol'] = "REQUEST_URI"

Conclusion:

These steps helped you to remove index.php from URL in Codeigniter Using .htaccess


No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...