I am learning CodeIgniter.I want to rewrite URLs so that localhost/tutorial/index.php/cart/product
becomes localhost/tutorial/cart/product
I tried to edit my .htaccess file inside the application folder with the following code:
RewriteEngine on
ReWriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
ReWriteRule ^(.*)$/tutorial/index.php/$1[L]
but it didn't work. My CI file name is tutorial and CI version is 2.0.
I have tried that .htaccess
file and it seems to work (note the extra spaces in the last line)
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /tutorial/index.php/$1 [L]
Also check if mod_rewrite
is enabled in your system (in Ubuntu and similar systems you can use a2enmod rewrite
: it should say that it is already enabled).