it’s really shame to say, having working experience of around 1 and 1/2 year in code igniter i forget how to use .htaccess for localhost. honestly, i have no problem with .htaccess(for localhost and server) when environment configured as “Port based WAMP server”. however, before i forget let me write
There are two ways of environment setup. You can either configure your PHP, MySql, Apache as General/Conventional way or “Port based”. Both are fine and just a matter of different taste. I feel, no one have huge advantage over other. To give you an idea, say our project name is aminul_fool. In genearl way we create a folder in our root/htdocs/www and browse project as http://localhost/aminul_fool. On the other hand, when your choice port based setup then you can put your project (aminul_fool) anywhere of your computer(not necessary to put it into your web root) and configure port from /bin/apache/apache2.2.8/conf/httpd.conf and lastly browse your project as http://localhost:420.
Make sure your you activate rewrite_module feature. If you use WAMP then to do so, first run wamp server. and left click
wamp (white icon) -> apache -> apache modules-> rewrite_module(put tick mark)
now your server is totally able to handle .htaccess request.
Well, .htaccess file contenet is completely different for different type of environemnt you choose. If you choose conventional way then here is the .htaccess file content
Options +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^\.htaccess$ – [F]
RewriteRule ^favicon\.ico – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /aminul_fool/index.php?/$1 [L]
And when it’s Port based environment setup or Web Server(www.aminul_fool.com) here is the .htaccess file content
Options +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^\.htaccess$ – [F]
RewriteRule ^favicon\.ico – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
That’s all !! Restart wamp(for localhost) and enjoy restful url like:
http://localhost/aminul_fool/controller_novice/function_sumon
and for your server (aminul_fool.com)
http://www.aminul_fool.com/controller_novice/function_sumon