Welcome Guest, Not a member yet? Register   Sign In
how to mod_rewrite for a CI app on a subfolder
#1

[eluser]+__+[/eluser]
let's say i have a uploaded my app to

http://www.mysite.com/myapp/

how should i go about writing the .htacess file to remove index.php from this app?

Searched on the forum but none of the suggestions worked for me.

i tried with the one from the wiki
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /myapp/

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

if i go to
http://www.mysite.com/myapp/ or http://www.mysite.com/myapp/index.php
i see that the default controller runs and loads default view, but cannot i load other controllers with

http://www.mysite.com/myapp/controller_2 -> gives a codeigniter 404 page
http://www.mysite.com/myapp/index.php/controller_2 -> gives browser's default "page not found" page
#2

[eluser]Kindari[/eluser]
This one should work.

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    #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 /myapp/index.php
</IfModule>

Note that the only thing you should change is the ErrorDocument command, that must be the full path including subdirectory to your index file. so in example.com/myapp/index.php it would be ErrorDocument 404 /myapp/index.php
#3

[eluser]+__+[/eluser]
that part is only valid if mod_rewrite is not installed, for my case it's installed and changing that part does not do anything.
#4

[eluser]+__+[/eluser]
turns out godaddy needed a different configuration, everything works fine now.




Theme © iAndrew 2016 - Forum software by © MyBB