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?

2
  • 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. Commented Sep 29, 2013 at 3:31
  • have a look in this post. Hope works - stackoverflow.com/questions/17852585/… Commented Sep 29, 2013 at 5:29

3 Answers 3

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>
Sign up to request clarification or add additional context in comments.

2 Comments

where can i find RewriteBase /trrr/ #this is folder name localhost/trrr
its your base ex: localhost/yourfoldername
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]

7 Comments

how it not working? either it still shows index.ph in link or what
I use the above code and removed index.php in config file, the url comes without index.php but but my webpage shows page not available
did you used index.php , in the url of that page?
Still i am facing same problem. do i have to do any apache config
i removed index.php in config file "$config['index_page'] = '';"
|
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.