The default URL display in the CodeIgniter app is not good to see because there is an index.php path. To remove index.php URL path CodeIgniter simply add a script to the .htacces file. Consider the following short tutorial.
Read another tutorial: Introduction – PHP Codeigniter Tutorial For Dummies Step By Step
PHP Codeigniter is a PHP framework that is liked by many people, for those of you who just do the installation CodeIgniter and access your project then you will surely see a less good view its URL like the example below:
1 | http://example.com/index.php/product |
Well so that better and easier to remember, then we will change its URL so like this
1 | http://example.com/product |
The way is quite easy, because we only need to make changes in config settings and create .htaccess file, okay now we will first create a file with the name .htaccess and we store in the root folder of our application, the contents of the file .htaccess as below:
1 2 3 4 5 6 | RewriteEngine On RewriteCond %{REQUEST_URI} ^/system.* RewriteRule ^(.*)$ index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php?/$1 [L] |
And the next step is to change the bit setting of the CodeIgniter configuration. Change default settings
1 2 | // application/config/config.php $config["index_page"] ="index.php"; |
Be like the following
1 | $config["index_page"] =""; |
Then please access your project with the above URL above, if successful should your controller can be accessed correctly, but if not successful there is possibility mod_rewrite module from Apache not yet active. The solution tries to open httpd.conf file and find the following script:
1 | #LoadModule rewrite_module modules/mod_rewrite.so |
And unmark #, so it looks like this:
1 | LoadModule rewrite_module modules/mod_rewrite.so |
After that, please restart apache and try to access. So my brief tutorial, hopefully, useful
Leave a Reply