New Perspectives On Web Design

(C. Jardin) #1

CHAPTER 8 How to Fix The Web: Obscure Back-End Techniques and Terminal Secrets


$ grep -i log /etc/apache2/apache2.conf
ErrorLog /var/log/apache2/error.log...

hTaCCeSS eRRoRS
It is very easy to screw up a website. You can quite readily bring down a
very big website by removing a single character from the .htaccess file.
Apache uses the file .htaccess to provide last-minute configuration options
for a website. It’s most often used for URL rewriting rules that look like this:
RewriteRule ^products/.*/([0-9]+)$ products/view.php?id=$1 [L,QSA]

This rule says to rewrite any URL in the form “products/
widget-3000/123” to the actual URL “products/view.php?id=123”. The L
means that this is the last rule to be applied and QSA means that Apache
should attach any query string to the new URL.
URL rewriting is often used for search engine optimization so that Web
managers can get the name of the product into the URL without actually
having to create a directory called “widget-3000”. However, make a single
typo and your whole website will give a 500 Internal Server Error.
The tail command will display the last 10 lines of a log file. Give it a -1
to display the single last line instead. An .htaccess problem will look like this:

$ tail -1 /var/www/vhosts/smashingmagazine.com/statistics/logs/error_log
[Thu May 06 11:04:00 2013] [alert] [client 81.106.118.59] /var/www/
vhosts/smashingmagazine.com/httpdocs/.htaccess: Invalid command 'Rewi-
teRule', perhaps misspelled or defined by a module not included in the
server configuration.

Or give it the -f option to follow the log file, showing any additional log
entries as they happen:

$ tail -f /var/www/vhosts/smashingmagazine.com/statistics/logs/error_log...

You can grep for all of these types of errors:
Free download pdf