CodeIgniter urls are designed to be search-engine and
human friendly.But, that by default 'index.php' which
appears in the url of codeigniter applications is really awkward.To maintain the standards I always remove the default 'index.php' from the codeigniter url so that the url becomes more
search engine friendly and looks clean.
So today in this tutorial I will show you how to remove index.php from codeigniter url.
That 'index.php' can be removed from the codeigniter url by following some simple steps.First we will create an '.htaccess' containing codes to remove 'index.php' from the codeigniter url.We will save that '.htaccess' file on root of that codeigniter applications. We will also make necessary changes on the configuration files of that codeigniter application.It is as simple as bellow :
Step I - Download Codeigniter : You can download Codeigniter 3 from their official website - https://www.codeigniter.com/download .You can also Download Github repository of Codeigniter 3 - https://github.com/bcit-ci/CodeIgniter .
Step II - Create .htaccess File : The next step is create an '.htaccess' file.First open your favourite text editor and create a new text file.Now save it as ".htaccess" in the root directory of that codeigniter application. Some time the file saved as a text file. To avoid this problem type the file name within quotes.
Now copy paste bellow code to the '.htaccess' file and save:
Step III - Modify Config.php File : Now in the next step we will make some changes on the 'config.php' file. Go to application>>config folder of your codeigniter application.Open the file 'config.php'.
First Search for the bellow line in 'config.php'.
Replace this line with the bellow line
Again Search for the bellow line in 'config.php'.
Replace this line with the bellow line
Now try to open your codeigniter application without 'index.php'. Hope it will open your application without 'index.php'. If your fell any problem on following those steps comment bellow. Thanks for reading this article.
So today in this tutorial I will show you how to remove index.php from codeigniter url.
That 'index.php' can be removed from the codeigniter url by following some simple steps.First we will create an '.htaccess' containing codes to remove 'index.php' from the codeigniter url.We will save that '.htaccess' file on root of that codeigniter applications. We will also make necessary changes on the configuration files of that codeigniter application.It is as simple as bellow :
Step I - Download Codeigniter : You can download Codeigniter 3 from their official website - https://www.codeigniter.com/download .You can also Download Github repository of Codeigniter 3 - https://github.com/bcit-ci/CodeIgniter .
Step II - Create .htaccess File : The next step is create an '.htaccess' file.First open your favourite text editor and create a new text file.Now save it as ".htaccess" in the root directory of that codeigniter application. Some time the file saved as a text file. To avoid this problem type the file name within quotes.
Now copy paste bellow code to the '.htaccess' file and save:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Step III - Modify Config.php File : Now in the next step we will make some changes on the 'config.php' file. Go to application>>config folder of your codeigniter application.Open the file 'config.php'.
First Search for the bellow line in 'config.php'.
$config['index_page'] = 'index.php';
Replace this line with the bellow line
$config['index_page'] = '';
Again Search for the bellow line in 'config.php'.
$config['uri_protocol'] ='AUTO'
Replace this line with the bellow line
$config['uri_protocol'] = 'REQUEST_URI'
Now try to open your codeigniter application without 'index.php'. Hope it will open your application without 'index.php'. If your fell any problem on following those steps comment bellow. Thanks for reading this article.