CodeIgniter Forums

Full Version: No 404 on existing folders
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey all,

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

The htaccess I use is
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
ERROR - 2015-04-12 15:50:19 --> 404 Page Not Found --> application
but yet doesn't show me a 404 error page...
There should be an htaccess file in both the system and application directories not allowing access (via url) by default. Are those present?
yes, these are all present. These say "Deny from all"
Anyone an idea perhaps?
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
thanks for you answer, I reset everything and came to conclusion it was this line what is causing the issue:

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 it seems to throw in weird symbols when visiting 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.
This is a somewhat wild guess, but shouldn't the following work (if placed before your existing rules)?

RewriteRule ^application/* - [F]
(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)?

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"
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.
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..

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:

but this gives the weirds symbols..

full log:
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:
$route['default_controller'] = "store";
$route['404_override'] = '';

server error log shows this line when I browse to the page and get the weird symbols:
[Sun Apr 19 17:10:42 2015] [error] [client] client denied by server configuration: /home/xxxxxxxx/domains/
So it says it is denying the access, yet it shows weird symbols,,
Pages: 1 2