I'm using below code in .htaccess for showing custom 403 error page on my website.
ErrorDocument 403 /403.php
Though I'm using ErrorDocument 404 /404.php for showing 404 page, and that's working correctly, But custom 403 is not working. It shows me this (See the image http://i.stack.imgur.com/4eTOM.png ) upon opening a restricted directory.
The server is running LiteSpeed. Can anyone help me out?
The sintaxis is good, try:
Make sure you're really having a 403 error with a var_dump(http_response_code());
remove this line from .htaccess, if you got the same result it's possible that the error is in other script file.
change the name of 403.php, if you got the same result it's possible that you have another "ErrorDocument 403" in the .htaccess.
change the name of 403.php and the "ErrorDocument 403" line too, if you got the same result it's possible that the error is in the 403.php script, you can't empty and put only a "test message" and try again now.
Related
How can i make it so that my htacces rules return a 404 when invalid urls are entered into the adress bar.
I use the virtualbox for one project and i try create one file .htaccess and i put one error 404 to protect my pages, but when i create my error 404 and sending to the server and refresh my page i have one error 500 on my server.
My code is this:
#my error 404
ErrorDocument 404/file/404.php
Anyone can help me?
I don't know why this happens and I have searched on google.
Greets
You have to wrap your path with quote to determine if it was string
ErrorDocument "404/file/404.php"
A Little White Space causes the issue
Change this
ErrorDocument 404/file/404.php
to
ErrorDocument 404 /file/404.php
Read more here
In codeigniter how do I redirect to a custom HTML page when 500 error occurs?
I have tried following code in .htaccess but it does not work:
ErrorDocument 500 /errors/error_500.html
error_500.html is my custom HTML page and its location is application/errors
The ErrorDocument directive, when supplied a local URL path, expects the path to be fully qualified from the DocumentRoot. In your case, this means that the actual path to the ErrorDocument is
ErrorDocument 500 /path/errors/error_500.html
try
ErrorDocument 500 http://localhost/errors/error_500.html
When you corrected it in your second try, the reason you see that page instead is because http://localhost/errors/error_500.html doesn't exist, hence the bit about there being a 500 error in locating the error handling document.
In Codeigniter actually it has a custom 500 error page.
So if you find your getting a generic 500 error page means, that it could be Apache overriding the codeiginter 500 error page.
You could also try to override it in the .htaccess to direct it to your own custom 500.html,
but then you will miss out any of the error information provided by codeiginter:
ErrorDocument 500 /errors/error_500.html
You could also edit the codeiginter 500 error page found in /application/errors/. I think it is the error_php.php file.
I am working on solving an issue within my Apache servers that will return a 403 Forbidden page when I attempt to go to a URL with sub-directories and the sub-directories do not exist.
"domain.com/etc/" Will return a 403 Forbidden error instead of a 404.
"domain.com/cd/" Will return a 403 instead of 404
"domain.com/xss/" Will return a 403 instead of a 404.
I've tried other URL/sub-directories like domain.com/bin/ returns 404. I've added this line to the HTACCESS file.
ErrorDocument 403 /error404.php
Which will make all 403 returns display a 404 page. However, this isn't good if the page is actually suppose to return a 403.
Anyone know how I can determine why these three sub-directories are returning with a 403 and not a 404. NOTE: I believe that these 3 are the only three I've been able to get to return a 403 Forbidden page on.
Is this an issue with the HTACCESS file, httpd.conf, Vhost.conf, or a php file? These directories DO NOT exist on the server. Any help would be much appreciated.
I've figured this out.
Mod_security rules crs_40_general_attacks and crs_41_xss_attacks are the cause. I've located the SEC_rules that are being called, commented those rules out and now I do not get the 403 error. The /cd is redirected to the landing page and the other two return 404 errors. :) Yeah for me :) Thanks to everyone that tried to help I truly appreciate it.
Iam trying to create error pages for my website, I created an .htaccess file with the following code:
ErrorDocument 403 /403.htm`
ErrorDocument 404 /404.htm
I also created the html files, I uploaded it in the root directory but it doesn't work.
Coould anyone tell me if I am doing anything wrong?
Thanks in advance
Blockquote
First, I would try something like adding this directive, and testing a 404 to see if it works:
ErrorDocument 404 "Sorry, no file here"
If you don't get that error, then in all likelihood your .htaccess file isn't being processed. You need to make sure that it's enabled on your server, etc. It is also possible that your ErrorDocument directive is specified somewhere that it isn't being read for the context where you are testing.
If you do get that error, the next thing I would do is make sure that your error documents are where you think they are. You mention that you uploaded them to the root directory of your project, so I would try browsing to them and see what happens.
i'm having this issue with my server, i'm trying to do a Error 404 display, but whn i go to an invalid URL i get this message.. Please where could the problem coming from?
The requested URL /church/ffff.php was not found on this server.
Additionallt, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request
thank you.
oh it's because the htaccess doesnt automaticly enabled on local host you need to do this:
click on wamp icon
apache->apache modules-> and enable rewrite_module
Whats your .htaccess look like?
You can add a custom handler like this:
In .htaccess (the top of it is best)
ErrorDocument 404 404.php
it seems like the server dont have accses to the 404 file, to fix this you should put the file in the same folder as your htaccess and instead of writing a full path(/c:wamp/www/church/404.php) you should just write the file's name - 404.php