CodeIgniter Forums
No 404 on existing folders - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: No 404 on existing folders (/showthread.php?tid=61391)

Pages: 1 2


No 404 on existing folders - BABYpanda - 04-12-2015

Hey all,

I noticed that when a user browses to example.com/application for instance, he doesn't get a 404 error page but instead get "‹ãRàâ xŽl" as output.

The htaccess I use is
Code:
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]

this seems to be an issue on all subfolders. If a folder doesnt exist I get a 404 error, but if a folder exists like applications it screws me over Sad

Any idea what I am doing wrong?

Thanks in advance.

PS. The error log gives
Code:
ERROR - 2015-04-12 15:50:19 --> 404 Page Not Found --> application
but yet doesn't show me a 404 error page...


RE: No 404 on existing folders - CroNiX - 04-12-2015

There should be an htaccess file in both the system and application directories not allowing access (via url) by default. Are those present?


RE: No 404 on existing folders - BABYpanda - 04-12-2015

yes, these are all present. These say "Deny from all"


RE: No 404 on existing folders - BABYpanda - 04-14-2015

Anyone an idea perhaps?


RE: No 404 on existing folders - gadelat - 04-15-2015

Few ideas:
-Your .htaccess file is pretty nonstandard, try to swap it with other configurations. E.g. with the one from docs.
-Your index.html files in sub folders may be corrupt. Try to rename them and see what happens
-Your .htaccess files in sub folders is maybe not correct. Try to rename them and see what happens


RE: No 404 on existing folders - BABYpanda - 04-15-2015

thanks for you answer, I reset everything and came to conclusion it was this line what is causing the issue:

Code:
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]

Any idea how I can still remove index.php for the url but yet receive a forbidden access when browsing to /application for example ?

EDIT: I found out this has something to do with it being a subdomain rather than a subfolder. When I change the config file the way it works it being a subfolder, everything is working perfectly. No weird symbols when visiting an existing folder like application. But when I change it to a subdomain eg test.example.com it seems to throw in weird symbols when visiting test.example.com/application instead of showing a 403 forbidden or anything similar.

I noticed that a trailing slash is being removed when its a subdomain, and not when it is a subfolder.


RE: No 404 on existing folders - mwhitney - 04-16-2015

This is a somewhat wild guess, but shouldn't the following work (if placed before your existing rules)?

Code:
RewriteRule ^application/* - [F]



RE: No 404 on existing folders - BABYpanda - 04-16-2015

(04-16-2015, 08:08 AM)mwhitney Wrote: This is a somewhat wild guess, but shouldn't the following work (if placed before your existing rules)?


Code:
RewriteRule ^application/* - [F]

Thanks for your reply though it doesn't seem to work.

The most interesting part is that I loaded a fresh copy and there happens exactly the same. It being a subdomain throws errors at me, while it being a subfolder seems to work flawless. The only thing I want to achieve is remove index.php from the url, and the htaccess given above doesn't seem to work with that properly.

PS. The output is always "‹ãRàâ xŽl" and the log always gives "ERROR - *time* --> 404 Page Not Found --> application"


RE: No 404 on existing folders - mwhitney - 04-17-2015

Do you have a RewriteBase directive?

Generally, I find mod_rewrite annoying because I spend a significant amount of time to get it working once on a server, and everything makes perfect sense at that point in time. However, when I need to do it again (often months or even years later), none of it makes any sense any more.

It probably doesn't help that Apache 2.4 changes a lot of things.


RE: No 404 on existing folders - BABYpanda - 04-19-2015

Thanks for your reply. The RewriteBase is set to "/" in the htaccess of the subdomain.

I really have no idea why it does these things, pretty much..

Code:
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

thats the .htaccess in the subdomain.

This url gives a correct 404 error:
http://test.example.com/index.php?/application

but this gives the weirds symbols..
http://test.example.com/application

full log:
Code:
DEBUG - 2015-04-19 16:32:32 --> Config Class Initialized
DEBUG - 2015-04-19 16:32:32 --> Hooks Class Initialized
DEBUG - 2015-04-19 16:32:32 --> Utf8 Class Initialized
DEBUG - 2015-04-19 16:32:32 --> UTF-8 Support Enabled
DEBUG - 2015-04-19 16:32:32 --> URI Class Initialized
DEBUG - 2015-04-19 16:32:32 --> Router Class Initialized
ERROR - 2015-04-19 16:32:32 --> 404 Page Not Found --> application

and routing settings:
Code:
$route['default_controller'] = "store";
$route['404_override'] = '';

server error log shows this line when I browse to the page and get the weird symbols:
Code:
[Sun Apr 19 17:10:42 2015] [error] [client xx.xx.xxx.xxx] client denied by server configuration: /home/xxxxxxxx/domains/example.com/public_html/xxxxxx/application
So it says it is denying the access, yet it shows weird symbols,,