I was looking for this over google and found just one thing repeated on every single website.
Edit your .htaccess and add this line:
ErrorDocument 404 /yourpage.php
So for example my page is error.php so it is obvious that it should be:
ErrorDocument 404 /error.php
However even if I type full domain name it doesnt works. It gives me Internal Server Error only and I have no ideas how to make it.
Any tips? Thanks.
EDIT No.1:
I am not quite sure where do I check for these "Apache" logs.
Btw here is full ISE Message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, *webmaster#mydomainname.com* and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Also I have tried making error.html and doesnt works. And also I Do not use any other rewrites in htaccess.
Then your webserver does not support this option...
Look into your http.conf and search for
AllowOverride <value>
If it is not equal FileInfo or all configuring error documents is not allowed.
Change it to All to make it work (and restart Apache afterwards)
If you do not have access to the http.conf, ask your Provider to allow custom error documents.
Related
If i try to access www.wordpress.com/codeigniter it is getting redirected to www.wordpress.com/en/codeigniter. If i change rewriterule in the .htaccess of wordpress to
RewriteRule ^(.*/)?codeigniter/(.*) /codeigniter/$1 [L]
Getting 500 internal server error. The server encountered an
internal error or misconfiguration and was unable to complete your
request.
Please contact the server administrator, webmaster#domain.com and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
Help me out to get this done please, Thanks in advance.
When someone is browsing a page on the internet let say
www.example.com/browse.php, if there is no internet access or that the page does not exist, it will display error eg **
Server not found
Firefox can't find the server at www.example.com/browse.php.
Check the address for typing errors such as ww.example.com instead of www.example.com
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.**
my question is how can i redirect those error to particular page eg error.php using .htaccess file
Thank You
You can't - the browser handles connection errors, not the server.
Besides - how in the world would your server find the custom error page, if it can't connect to the server in the first place?
you can define custom error page handle in apache .htaccess file:
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
I have a bunch of ErrorDocument directives in my .htaccess file in order to catch almost all the possible errors Apache can throw at a user, and to redirect said user to my error controller which would then render the error in a more user friendly manner. However, it does not seem work.
For instance, when I enter an invalid URL like mysite.com/""##$##$! I always get Apache's default 403 error message, instead of a redirect to my errors.php file. Below is the directive I'm using. Do I need to do anything else to make it work? (AllowOverride All is set)
ErrorDocument 403 /errors.php
If this is the wrong way to approach absolute custom error handling, please let me know, I would appreciate a nudge in the right direction.
Thank you!
Edit:
Oh, just thought I'd mention this. I wrote my own MVC structure for redirecting the request, and it works well. From within PHP, if a user requests a nonexistant URL, my own 404 error will fire just fine (or whatever other error I have defined). So basically, if I enter mysite.com/!!!! into the URL, it will work and I get a 404. However, whenever I start a request with the double quote character, the default Apache 403 error fires. Odd. Also, a 500 error will fail to redirect to errors.php as well, and will simply return a default Apache 500 screen (for instance, when testing with header("HTTP/1.0 500 Internal Server Error");die();).
Edit 3: I just tried placing ErrorDocument 200 "message" in my .htaccess file and nothing happened, any page I open opens normally. Worst case scenario, this should get stuck in an infinite loop. Best case scenario, it should output "message". It did neither, it simply ignored ErrorDocument. Apache's Access Log notes a normal 200 OK header, and yet it was completely ignored by .htaccess.
A few different mis-conceptions in the question. The following PHP code:
header("HTTP/1.0 500 Internal Server Error");
die();
Will never trigger an Apache error page - it's triggering your browser's default error page. Once control has been given over to PHP, it does not go back to Apache for error handling.
ErrorDocument only works for error codes, not success codes. It's in the docs
Syntax: ErrorDocument error-code document
http://httpd.apache.org/docs/current/mod/core.html#errordocument
If you were mistaking one kind of browser error page for a server error, then that might be the cause of your main problem too. Unless your custom error handler outputs a certain amount of data, some browsers will always show their own error pages. Make sure your output is at least a few kilobytes in size.
The cause of your problem is most likely just Apache's built-in behavior combined with your choice of test URLs. From the ErrorDocument docs:
Although most error messages can be
overriden, there are certain
circumstances where the internal
messages are used regardless of the
setting of ErrorDocument. In
particular, if a malformed request is
detected, normal request processing
will be immediately halted and the
internal error message returned. This
is necessary to guard against security
problems caused by bad requests.
Edit: How to simulate a 500 error in Apache. My first thought was syntax errors in .htaccess, but this wont trigger custom error handlers. The easiest way I found was to enable CGI in .htaccess by adding these lines:
ErrorDocument 500 /500.php
Options +ExecCGI
AddHandler cgi-script .pl
And then adding a perl script that crashes:
#!/usr/bin/perl
safasfdsfdd_(*EYFIUOBAF(_*AS^FD_(*AWHD{
You will need to make sure the perl script is executable by apache's user. This shows my custom 500 handler.
However, you're very unlikely to ever trigger an Apache 500 when using PHP, so this probably isn't a useful test.
I just use .htaccess for all custom error pages
ErrorDocument 401 /error/PHP/server-error.php?error=401
ErrorDocument 403 /error/PHP/server-error.php?error=403
ErrorDocument 404 /error/PHP/server-error.php?error=404
ErrorDocument 500 /error/PHP/server-error.php?error=500
ErrorDocument 503 /error/PHP/server-error.php?error=503
Since it's a friday, I can't ask my host about this, but apparently, all the .php pages on my websites are giving out the "Internal Server Error"... this started just now, I was not on my admin cp, I did 0 changes to my website today, in fact, I changed nothing for about a week now.
I host a few forums and got alerted by some users just now who were browsing and suddenly this happens.
The website in question:
cudamine.com
The error:
Internal Server Error
The server encountered an internal
error or misconfiguration and was
unable to complete your request.
Please contact the server
administrator, xxx#email.com and
inform them of the time the error
occurred, and anything you might have
done that may have caused the error.
More information about this error may
be available in the server error log.
Additionally, a 404 Not Found error
was encountered while trying to use an
ErrorDocument to handle the request.
I use cPanel X.
Should I be worried about this? Some sort of attack or something? All HTML pages work fine, it's just .php that seems to have this issue, is this a problem on my hosts end, or can I do anything about this before monday? Thanks guys, and sorry if this is the wrong place to ask. It's just that I don't want to have no site for the whole weekend...
After reading up on the web about similar situations, I found some info on the .htaccess file, I found the file and this is what's in it:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^cudamine.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.cudamine.com$
RewriteRule ^santa\-maria\/forum\/?(.*)$ "http\:\/\/cudamine\.com\/santa\-maria\/\?page_id\=7\/$1" [R=301,L]
Those two RewriteCond are 2 of my links that use php... I tried deleting this file, nothing changed though.
Definitely check the error log (should be available in CPanel).
One common occurrence I see is when a host enables SuPHP (suexec for PHP scripts) and you have group writable scripts or directories containing scripts.
If your error log shows anything like "Apache SoftException", then this is the most likely cause. You need to change the filesystem permissions on your scripts and directories to remove the group "write" bit.
Another possible cause is your host has disabled mod_rewrite or removed the appropriate overrides (FileInfo) to use the Rewrite* directives.
PHP may be writing its error log elsewhere than the standard Apache error_log. You can retrieve the log's location with ini_get('error_log'). If the value's something other than "syslog", PHP is writing its errors to a file of the same name.
Every time I return some status code in my PHP code, Zend Server gives me following error appended on the bottom of my website (with the message of HTTP code I returned). So for example, if I return 401, it gives me another 401 error appended to my 401 page:
Is there any way to turn it off? I use Zend Server Community Edition 5.0 with PHP 5.2.
EDIT:
It seems to be default Apache error handling. Is there a way to disable it? Preferably without having my own error pages.
ADDITIONAL EDIT:
I tried to edit my .htaccess with ErrorDocument directives. It still gives me my error page (blank page) + Apache error (like on screenshot above).
This isn't happening with ZendServer 4 I have on server. I use ZendServer 5 on localhost tho. Is it possible to be some kind of bug or misconfiguration from Zend side?
BEHAVIOUR:
(In all test cases I return 401)
When I use default ZendServer configuration + ErrorDocument directives in .htaccess, I get my own error page + Apache error page appended bellow it.
When I use default ZendServer configuration + disable my own ErrorDocument directives, I get just Apache error page.
When I change Apache error pages to blank files + use my own ErrorDocument directives, I get the desired behavior, however errors 404 still append default Apache errors bellow my own.
As you can see on the Apache httpd documentation page, you can't disable it.
If you just want no output you have two choices:
# you *HAVE TO* to put at least one character (here it's a space)
ErrorDocument <errorcode> `' '`
# if you really want to have 0 character, use a blank file
ErrorDocument <errorcode> /var/www/blank
Though you have to this for each error code you want to "disable".
You can make these changes in the httpd server's conf file or in a .htaccess file or a VHost (though I don't know where are the conf files in Zend Server).
I don't think you'll necessarily want to "disable" that error. What you need to do is find out what error is being reported (go through the log file) and then you'll probably find a permission issue or a PHP script that's actually failing and dumping it's core.
To override a default error page in apache, you can place the following line in an .htaccess file or in you httpd.conf config.
ErrorDocument 401 /path/to/the/new/error/page.html
that applies to all error pages you want to override. So just change the status code to 503 for those errors..etc..
More info in the apache documentation: http://httpd.apache.org/docs/1.3/mod/core.html#errordocument