1

I cannot able to remove index.php from url in codeigniter i have tried this .htaccess file code.

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

and

i removed index.php in config file

How to solve this problem?

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
Serma
  • 44
  • 1
  • 2
  • 11
  • if you are on localhost and you are not using virtualhost you have to add `RewriteBase` on your `htaccess` to redirect it to the folder. – tomexsans Sep 29 '13 at 03:31
  • have a look in this post. Hope works - http://stackoverflow.com/questions/17852585/how-to-call-codeigniter-controller-function-without-url-without-index/17852790#17852790 – Sharif Sep 29 '13 at 05:29

3 Answers3

0

first you have to enable rewrite_module in Apache server
then your .htaccess file should be like this -->

> <IfModule mod_rewrite.c>
>     RewriteEngine On
>     RewriteBase /rttt/
> 
>     #Removes access to the system folder by users.
>     #Additionally this will allow you to create a System.php controller,
>     #previously this would not have been possible.
>     #'system' can be replaced if you have renamed your system folder.
>     RewriteCond %{REQUEST_URI} ^system.*
>     RewriteRule ^(.*)$ /index.php?/$1 [L]
>     
>     #When your application folder isn't in the system folder
>     #This snippet prevents user access to the application folder
>     #Submitted by: Fabdrol
>     #Rename 'application' to your applications folder name.
>     RewriteCond %{REQUEST_URI} ^application.*
>     RewriteRule ^(.*)$ /index.php?/$1 [L]
> 
>     #Checks to see if the user is attempting to access a valid file,
>     #such as an image or css document, if this isn't true it sends the
>     #request to index.php
>     RewriteCond %{REQUEST_FILENAME} !-f
>     RewriteCond %{REQUEST_FILENAME} !-d
>     RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>
> 
> <IfModule !mod_rewrite.c>
>     # If we don't have mod_rewrite installed, all 404's
>     # can be sent to index.php, and everything works as normal.
>     # Submitted by: ElliotHaughin
> 
>     ErrorDocument 404 /index.php </IfModule>
Senanayaka
  • 309
  • 6
  • 18
0

Please use this code

RewriteEngine on
RewriteBase / -- Your folder containing htaccess file-- / 
# Hide the application and system directories by redirecting the request to index.php

RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
0

please try the code below.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

put the code in your root folder htaccess file. Its working for me.please let me know if it's working for you or not.

ABorty
  • 2,512
  • 1
  • 13
  • 16