CodeIgniter Forums
CI 2.2.6 subfolder route 403 error - Printable Version

+- CodeIgniter Forums (
+-- Forum: Development (
+--- Forum: CodeIgniter 2.x (
+--- Thread: CI 2.2.6 subfolder route 403 error (/thread-64071.html)

CI 2.2.6 subfolder route 403 error - cvetan - 01-10-2016

I have the subfolder admin in controllers folder so it looks like this.



The problem is this i want when i enter only admin in url it goes to sessions controller. And i have set this route
$route['admin'] = 'admin/sessions/login';

But when i try to access site_url/admin i get 403 forbidden error. Am i doing something wrong?  Huh

I think i figure out what the problem is.

I have folder in public part that is called admin. And it tries to display content of that folder, instead of calling the controller route.

The whole folder structure is like this:

I know that this kind of setup worked for me before, or maybe something similar. What am i doing wrong now? Huh

RE: CI 2.2.6 subfolder route 403 error - Diederik - 01-11-2016

You need to remove the fysical admin folder, or ajust your .htaccess file. By default it is configured to redirect all requests to non existing files or folders to index.php.
Since the folder exists in your structure you don't access your admin controller. You can a) tweak your .htaccess into ignoring the existense of an admin folder or b) change your folder structure to something like: /assets/admin/css|js|fonts for example.

RE: CI 2.2.6 subfolder route 403 error - cvetan - 01-11-2016

How do i tweak .htaccess?

RE: CI 2.2.6 subfolder route 403 error - Diederik - 01-11-2016

To be honest I dont know exactly, I'm not a apache config (.htaccess) guru. You will have to do some research, trial and error etc.

It's easy to have /admin/ redirected to /index.php so you can use it as a controller name (even if the folde exists) but that will also set /admin/css/somefile.css to use that same controller and try to call a method called 'css' etc.
You could make a css,js,img method in the admin controller to read the file inside the admin folder but to serve those kind of files through php for this reason is just bad practise and horrible performance wise.

The easiest thing to do I guess would be to just rename the admin folder (something in the line of assets, or seperate those files into /js/admin/file.js, /css/admin/other.css etc) or use a different controller name like 'administrator', 'cms' etc).

RE: CI 2.2.6 subfolder route 403 error - cvetan - 01-12-2016

I think i will rename admin controllers folder.

Thanks for advices. Smile