CodeIgniter Forums
Removing index.php in Codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Removing index.php in Codeigniter (/showthread.php?tid=57759)

Pages: 1 2 3 4 5


Removing index.php in Codeigniter - El Forum - 04-11-2013

[eluser]Edy S[/eluser]
If your mod_rewrite curently enable, try this htaccess file and put on your codeigniter folder.
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /your_ci_folder_name/index.php/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt) write name of folder that allow to access via http
for example : RewriteCond $1 !^(index\.php|images|js|robots\.txt)
All name listed on that line will allow to access via http, i've use that code on my site :
http://www.media-kreatif.com


Removing index.php in Codeigniter - El Forum - 04-11-2013

[eluser]TheFuzzy0ne[/eluser]
You may also want to try changing the value of $config['uri_protocol'] in ./application/config/config.php. Sometimes CodeIgniter gets it wrong. Changing it to PATH_INFO might work.


Removing index.php in Codeigniter - El Forum - 04-13-2013

[eluser]faisal_memon[/eluser]
@TheFuzzy0ne It worked !! Thanks a lot !!


Removing index.php in Codeigniter - El Forum - 04-15-2013

[eluser]drewdin[/eluser]
I am having the same issue that I have been struggling the last two days with. I want to remove index.php from my urls, when its there everything works fine. When i remove it, i get:

Not Found

The requested URL /CodeIgniter/home/index was not found on this server.

Heres my setup:
Mac OSX
MAMP
www/CodeIgniter/applications

Heres my .htaccess in the root folder CodeIgniter
Code:
#Deny from all
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /CodeIgniter/

    #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} ^core.*
    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>

I have
Code:
$config['uri_protocol'] = 'AUTO';
but i have also tried QUERY_STRING and PATH_INFO and both didn't work.

I have my index path setup
Code:
$config['index_page'] = '';

Any suggestions are welcomed, i am pulling all of my hair out! thanks


Removing index.php in Codeigniter - El Forum - 04-16-2013

[eluser]Unknown[/eluser]
On most servers none of these will work, the correct method is:

1: index.php from the config so it is just: $config['index_page'] = '';
2: Copy the following into your .htaccess file remember to put ? in front of index.php
so it's:

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]




Removing index.php in Codeigniter - El Forum - 04-16-2013

[eluser]TheFuzzy0ne[/eluser]
Just out of interest, what happens when you go to www.yoursite.com/application? Do you still get the same error, or do you see the home page for your Web site?

Please try changing:
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

to:
Code:
RewriteRule ^(.*)$ /index.php?/$1 [L]

And also ensure that mod_rewrite is enabled.


Removing index.php in Codeigniter - El Forum - 04-16-2013

[eluser]drewdin[/eluser]
I verified that mod_rewrite was enabled, if I browse to the path
Code:
http://localhost/CodeIgniter/
the controller works fine. if i browse to
Code:
http://localhost/CodeIgniter/about
i get the following error.

Quote:Not Found

The requested URL /CodeIgniter/about was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

if I use
Code:
http://localhost/CodeIgniter/index.php/about
it works fine



Removing index.php in Codeigniter - El Forum - 04-16-2013

[eluser]TheFuzzy0ne[/eluser]
You only answered one of my questions. Smile

What happens when you comment out the RewriteBase directive?


Removing index.php in Codeigniter - El Forum - 04-16-2013

[eluser]drewdin[/eluser]
Sorry about that, I modified my .htaccess file from
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]
to
Code:
RewriteRule ^(.*)$ /index.php?/$1 [L]
and nothing changed, it still fails.

If i comment out the rewrite base, nothing changes. My home page works but that's it.

I am still using the code below for my .htaccess.

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /CodeIgniter/

    #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. core/system
    RewriteCond %{REQUEST_URI} ^core.*
    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>

Is this not the recommended one to use? Thanks


Removing index.php in Codeigniter - El Forum - 04-16-2013

[eluser]TheFuzzy0ne[/eluser]
Did you try commenting out the RewriteBase directive?