Separate directories for web files and CI files |
Hey everybody, I'm learning CI coming from an extensive CakePHP background and so far I'm liking it a lot. From a 50,000-foot view, it seems like there's a lot less sludge to CI than there is to Cake. It's easier to get the common things done in CI than it is in Cake.
Except following common security practices by setting up separate directories for web files (images, scripts, stylesheets, uploads, etc.) and application files (CI core files, models, controllers, views, etc.). I've been all over Google, Stack Overflow, and these forums and I've found no solution. Here's a closer look at my setup:
Now, the project structure:
Code: <IfModule mod_rewrite.c> The .htaccess file in the /web folder forwards requests to index.php. Here are its contents: Code: <IfModule mod_rewrite.c> So, here's my problem: I am accessing the application at http://localhost/PROJECT, but for some reason CI is picking the PROJECT term out of the URL and processing it as the default controller, which causes it to try to render Project/index, which doesn't exist. As a result, it throws a 404 error and writes this message to the log file: Code: DEBUG - 2015-05-08 23:32:33 --> UTF-8 Support Enabled Sorry for the wall of text, I've been struggling with for almost two days now. If anyone has a pearl of wisdom they could share, I'd be grateful.
Try adding a rewritebase to your htaccess.
RewriteBase /PROJECT/ What do you have for your base_url in config? http://localhost/PROJECT/ ?
(05-10-2015, 04:29 PM)CroNiX Wrote: Try adding a rewritebase to your htaccess. I had a rewrite base in there at one point (it was just /PROJECT/) but it was causing infinite redirects whixh of course Apache wouldn't tolerate. And yes, my base_url was http://localhost/PROJECT/, though I think I read somewhere that you should leave base url blank if you're using rewrite. Or it might have been index file? Thanks for the help.
If possible, you should configure your server to use the web directory as the root (DocumentRoot in Apache). Then the rewrite directives are used primarily to remove index.php from the URL and don't have to deal with the sub-directory, because anything above the web directory is not accessible to the outside world.
Bonfire has a similar structure, and just uses an index.php in the main directory to tell you the server needs to be configured to point to the "public" sub-directory instead of the root directory, and the .htaccess file in the main directory simply disables indexes. |
Welcome Guest, Not a member yet? Register Sign In |