If you are using Codeigniter you are noticed that by default index.php will be included with your URL. We should remove index php codeigniter because its very ugly to have it in all the urls. So lets see how to remove index.php from url in Codeigniter from Apache and Nginx Servers separately
I will tell you how to remove index.php from url from codeigniter in apache and nginx server.
Contents
Htaccess Code to Remove index.php from URL from Codeigniter in Apache Server
Create a “.htaccess”file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it:
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Remove index php from URL from Codeigniter in Apache Server (Sub Directory)
If your codeigniter application is located in subdirectory then please include this line RewriteBase /subdirectory/
RewriteEngine on
RewriteBase /subdirectory/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Code to Remove index php from url from Codeigniter in Nginx Server
If your Codeigniter application is on Nginx server, then please include the below in your nginx.conf file under server block
location / {
try_files $uri $uri/ /index.php?$args;
}
Once you updated the changes in your server then you can access the urls without index.php
Before updating the code, your url looks like
http://ci.w3lessons.info/index.php/memcached
After you made the changes, your url looks like
Please check my codeigniter posts and tutorials
- How toremove index.php from Codeigniter URL ?
- How to Implement Memcached in PHP CodeIgniter
- Facebook Wall Script 5.0 – Sharing Posts, Message Filtering, Instant Notifications & many more
- Facebook Wall Script 4.0 with PHP Codeigniter MVC Framework
- Codeigniter Tips and Tricks
- How to execute cron job in codeigniter using PHP
- Useful Codeigniter Tutorials and Resources – Part I
Please subscribe to my blog to get latest updates via email.
Thanks
I have some doughts in codeigniter,
*how to import my codeigniter project into go daddy server
Just like any other project hosting. Use filezilla, that will help a lot.
does codeigniter have any conflict with GoDaddy server while hosting ?
I mean Codeigniter 3.0 which has the mysqli driver ?