Our social:

Thursday

Removing index.php In CodeIgniter But Getting An Error Message???


Have you tried tirelessly with no avail to remove "index.php" from your CodeIgniter url? I have, and after searching for like forever through the net for the solution, here is what finally worked for me.

Getting errors such as "500 internal error", "<IfModule takes one argument, Container for directives based on existence of specified modules" ... read on to solve this problem.


Removing "index.php" is done through the use of an .htaccess file that you place in the root folder & applications folder of your CodeIgniter application and enabling rewrite_module on your Apache server.

Well here is the .htaccess I used.

 <IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt)
RewriteCond $1 !^(index\.php|application/views/|robots\.txt|install|favicon\.ico|documents)
RewriteRule ^(.+)$ index.php?$1 [L]
RewriteBase /codeIgniter
DirectoryIndex index.php


#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> 


Notice the DirectoryIndex index.php that's the line I added that did the magic!

0 comments:

Post a Comment