500 Internal Server Error htaccess Test and Configure
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=KShYiHcLMTI
.htaccess | Configuring and Testing Custom Error Responses | 500 Internal Server Error page example • Author: Dmytro Dzyubak http://www.dzyubak.com • intro and outro music by Dmytro Dzyubak • Transcript • Configuring and testing customized 500 Internal Server Error page using .htaccess file. • Testing the custom 500 error page is actually trickier then one might think! Because usually we won't be able to trigger it neither with PHP code nor with the error intentionally made in the .htaccess file itself. The foregoing behaviour will be demonstrated in the examples that follow. • But let's first look at the contents of our DocumentRoot. What concerns us is an .htaccess file, 500.html, buggy.cgi, buggy.php and hello.cgi. 500 page header centrally-aligned is what we eventually want to achieve showing up in our browser. • So as I've already mentioned, we won't be able to trigger the output of this 500.html file with PHP code. For example, we can throw an exception (then open buggy.php to see the result) or introduce a fatal error directly (saving the document, refreshing the page) or send a raw 500 HTTP header (save the file, refresh). All these lines produce a blank page instead. We can confirm it by viewing the source. • In fact, it is possible to trigger 500 status code, but not the custom 500.html page. • Screwing up the .htaccess file itself, for example, with a double slash comment not valid in Apache produces a generic error response instead, but not our custom one that we need for testing our configuration. • However, we can intentionally generate an error by using the CGI script. Actually, CGI script can be implemented in PHP, but that's usually not the case, so let's not overcomplicate this stuff. • For CGI program to be executed properly by the server: enable the CGI module and restart the Apache. This procedure varies depending on the OS you use. • For example, on Debian Linux these commands look like this. Elevate privileges with sudo (or just might be a root user). This (a2enmod) stands for Apache 2 enable module CGI. And CGI stands for common gateway interface. After that restart the Apache with sudo service apache2 restart . • Add the following lines to the .htaccess file. This line (Options +ExecCGI) specifies that CGI execution is permitted. And this one (AddHandler cgi-script .cgi) makes any file containing the .cgi extension to be treated as a CGI program. • The CGI script has some garbage text that produces an error. • Make the script executable (chmod 755 buggy.cgi) and ls -l to ensure that the changes have been applied. • The following output shows that executable bit has been set on the buggy.cgi file. • Now we access our buggy.cgi script. (I type buggy.cgi and hit Enter.) • Ultimately we can see that our custom 500.html file is served when we have some problems with the server. • And just in case you've been wondering how a valid CGI script might look like, here I've added hello.cgi script. Navigating to hello.cgi gives the following output. • like / subscribe :-)
#############################
