Welcome Guest, Not a member yet? Register   Sign In
HTACCESS file doesent work in sub-folder

I am using the htaccess code that was given in codeigniter's user guide:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

it only works if the installation is located in the root directory. if it's located in a sub-folder, it doesen't work.

any idea how to make it work also under sub-category?


RewriteEngine On
RewriteBase /subfolder/

// ... other stuff ...

thank you very much for replying,
but the problem is not solved.

I still can't access any controller, it gives me an error.

if I try to import a css file, and using the next address:

it redirects me to:

but if I add http://www, it works.


Thats because each CodeIgniter folder has its own .htaccess file.

The one you are trying to use should be placed in the root with index.php

Here is a correct .htaccess file:
php_value default_charset utf-8

Options FollowSymLinks
Options -Indexes
DirectoryIndex index.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

would you explain how it works?
how does it recognize when to redirect and when not to?

Assuming that CodeIgniter is in ci-folder - this one works for me:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ci-folder/index.php/$1 [L]


As it was said in first answer. You must add CSS and other folders to RewriteCond if You don't want them to be treated by RewriteRule.

thank you very much!!

but now there's a problem:

if I give a link from the view file to external source:
<a >

it links to:


If this is true, .htaccess is don't responsible for that.

Theme © iAndrew 2016 - Forum software by © MyBB