Removing index.php in codeignter url is helps to improve SEO, so here we are going to do that by using .htaccess file. let's see how that works, we have already discussed more tutorials about .htaccess file, that helps to shorten the url make SEO friendly url to our project. this is very simple method to make it easy.
LIVE DEMO
STEPS TO REMOVE INDEX.PHP
In project folder application->config->config.php like the below image.
We have remove the both highlighted in above image, like the below image.
if $config['uri_protocol] = 'REQUEST_URI'; don't change it.
in case of older version codeigniter that will be as
$config['uri_protocol'] = 'AUTO'; means
you have change it to 'REQUEST_URI'; like the below image.
Then we have to create .htaccess file, refer the below image where to add .htaccess file.
Once .htacess file is created, in that we have to add some code.
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
the above code we need to add in .htaccess file. that's all now you can access codeingiter with and without index.php in url.
i hope this tutorial will help you a lot, keep supporting us for more tutorials. stay connected with in all social media.
No comments:
Post a Comment