CodeIgniter Forums
HTACCESS file doesent work in sub-folder - 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: HTACCESS file doesent work in sub-folder (/showthread.php?tid=53318)



HTACCESS file doesent work in sub-folder - El Forum - 07-18-2012

[eluser]yNaxon[/eluser]
hello,
I am using the htaccess code that was given in codeigniter's user guide:

Code:
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?

thanks


HTACCESS file doesent work in sub-folder - El Forum - 07-18-2012

[eluser]Aken[/eluser]
Code:
RewriteEngine On
RewriteBase /subfolder/

// ... other stuff ...



HTACCESS file doesent work in sub-folder - El Forum - 07-19-2012

[eluser]yNaxon[/eluser]
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:

example.com/subfolder/css/css.css
it redirects me to:
example.com/subfolder/example.com/subfolder/css/css.css

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




HTACCESS file doesent work in sub-folder - El Forum - 07-19-2012

[eluser]InsiteFX[/eluser]
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:
Code:
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]



HTACCESS file doesent work in sub-folder - El Forum - 07-19-2012

[eluser]yNaxon[/eluser]
would you explain how it works?
how does it recognize when to redirect and when not to?


HTACCESS file doesent work in sub-folder - El Forum - 07-19-2012

[eluser]blekknajt[/eluser]
Assuming that CodeIgniter is in ci-folder - this one works for me:

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

added:

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.


HTACCESS file doesent work in sub-folder - El Forum - 07-20-2012

[eluser]yNaxon[/eluser]
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:

http://www.example.com/http://www.anotherexample.com/



HTACCESS file doesent work in sub-folder - El Forum - 07-21-2012

[eluser]blekknajt[/eluser]
If this is true, .htaccess is don't responsible for that.