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

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

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

// ... other stuff ...
#3

[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.

#4

[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]
#5

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

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

[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/
#8

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




Theme © iAndrew 2016 - Forum software by © MyBB