Welcome Guest, Not a member yet? Register   Sign In
htaccess in subdir returns error

[eluser]José Carlos[/eluser]

I have CI running with my server root folder, wich has this .htaccess:

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|css|js|rss20.xml|images|editorial|testes|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

The problem is:

if I try to protect the editorial, or any other folder listed in the RewriteCond, with a .htaccess, it returns a "404 Page Not Found - The page you requested was not found" error.

How can I protect subfolders with htaccess? Wich modifications must I do? If you could please help me, I'd appreciate it.

Thanks in advance,

[eluser]Glen Swinfield[/eluser]
Put a .htaccess file in the folder you want to protect with the command

RewriteEngine off
deny from all

Also this might help: .htaccess files.

[eluser]José Carlos[/eluser]
Thank you for the fast response.

It still doesn't work. I've already tried those you've suggested and other, but it doesn't work anyway.

Thanks. I'll keep searching. If anyone has a suggestion, go ahead and give it.

[eluser]Glen Swinfield[/eluser]
Are you wanting to password protect the folder with .htaccess - or just generically prevent access from the public?

What page are you requesting to get the 404 error?

also the '.' in rss20.xml should be escaped rss20\.xml - I don't know if this is a typo in the post or actually in your code.

Do you want to protect your 'editorial' folder (ie: disallow access to it) or do you want to allow specific access to it?

If you're getting a 404 when you try to access it, then I'd say it's pretty well protected ;-) However, if you want to use HTTP Authentication, then you'd need to add it as you have done (escaping rss20.xml with rss20\.xml) as Codepat mentioned and then you can go ahead and add a second .htaccess file with HTTP Authentication specifics in the 'editorial' folder itself.


Have you found a way around this problem yet?

I am having the same issue. I am using CI 1.5.3 and have the following .htaccess fie in my main directory (located in /home/client/public_html):

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|cms|scripts|ssi|slideshow|sifr|tinymce|filemanager|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

I have a folder called cms that I would like to restrict access to one user using basic authentication. I set it up using cpanel and currently have the following .htacess:

RewriteEngine off
AuthType Basic

AuthName "cms"

AuthUserFile "/home/client/.htpasswds/cms/passwd"

require valid-user

I get a 404 when trying to go to the cms folder.

Has anyone come across this issue before? Could it be the rewrite causing problems with the location of the password even though it sits a level below it on the server?


[eluser]José Carlos[/eluser]
I'm still hving the same problem. And benmanson as put it way better than I have.

I have the exact problem he has. A dir, inside CI root, that has a .htaccess the same as benmanson's. If I add the folder's name to the list in the root's .htaccess, all is good, and I have access. But, if I want to protect it with basic authentication, as soon as I put a .htaccess inside it, I no longer can access it, and CI returns a 404.

If anybody can help, I'd appreciate it.

Thanks in advance,

I am having this problem now, I have a back-end application which is not part of the CI app, and if I use htccess to protect it I get CI's 404 error...

Any help would be greatly appreciated!


I couldn't resolve this problem so I ended up integrating a simple user authentication system (I used SimpleLogin). It might not be an option for you but it solved things for me.

Hope that helps.


The problem is our project allotted 5 minutes for setting directory permissions, now it's going on days...integrating an authentication system is definitely not an option. Now my boss is angry at me for using CI!

Theme © iAndrew 2016 - Forum software by © MyBB