Welcome Guest, Not a member yet? Register   Sign In
CI 2.2.6 subfolder route 403 error
#1

(This post was last modified: 01-10-2016, 08:37 PM by cvetan.)

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

controllers
   admin
       sessions
       pages

etc...

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

UPDATE
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:
application/controllers/admin/...
system/
public/index.php
public/admin/csss|js|fonts...

I know that this kind of setup worked for me before, or maybe something similar. What am i doing wrong now? Huh
"Well, if crime fighters fight crime and fire fighters fight fire, what do freedom fighters fight?"
Reply
#2

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.
Reply
#3

How do i tweak .htaccess?
"Well, if crime fighters fight crime and fire fighters fight fire, what do freedom fighters fight?"
Reply
#4

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).
Reply
#5

I think i will rename admin controllers folder.

Thanks for advices. Smile
"Well, if crime fighters fight crime and fire fighters fight fire, what do freedom fighters fight?"
Reply




Theme © iAndrew 2016 - Forum software by © MyBB