<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>AskApache</title>
	
	<link>http://www.askapache.com</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Fri, 17 May 2013 23:28:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<feedburner:info uri="apache/htaccess" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.askapache.com/apache/htaccess" /><feedburner:emailServiceId>apache/htaccess</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.askapache.com/apache/htaccess" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:browserFriendly>Thanks for your Interest, you are very nice!</feedburner:browserFriendly><item>
		<title>Show Events that Occurred on this day in the Past</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/gsxi7n4v774/show-events-occurred-day-linux.html</link>
		<comments>http://www.askapache.com/linux/show-events-occurred-day-linux.html#comments</comments>
		<pubDate>Fri, 17 May 2013 02:15:41 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[shell-script]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8924</guid>
		<description><![CDATA[<p><p><a class="IFL" href="http://www.askapache.com/linux/show-events-occurred-day-linux.html"><img src="http://uploads.askapache.com/2013/05/linux-calendar-example-5-16.png" alt="linux-calendar-example-5-16" width="447" height="85" /></a>This simple linux function will output a list (usually about 4-10) of events that occurred in the past on the same day.  So if you run on May 16 it will show you past events that happened on that date.<br class="C" /></p></p><p>The post <a href="http://www.askapache.com/linux/show-events-occurred-day-linux.html">Show Events that Occurred on this day in the Past</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/linux/show-events-occurred-day-linux.html"></a><a href="http://www.askapache.com/linux/show-events-occurred-day-linux.html"><cite>AskApache.com</cite></a></p><h2>The Function: askapache_calendar</h2>
<p>Note the screenshot is awesome due to my <a href="http://www.askapache.com/linux/fast-vimrc.html">custom .vimrc</a>.  It is missing the randomized color in the code below.</p>
<p><img src="http://uploads.askapache.com/2013/05/linux-calendar-in-vim.png" alt="Show Events that Occurred on this day in the Past" width="891" height="307" title="linux calendar in vim" /></p>


<h3>Download OpenBSD Calendars</h3>
<p>By default this script will use any calendars in your home directory <code>~/.calendars</code>.  If that directory does not exist when you call this function, it will tell you it is installing the calendars for you.  It grabs the list of calendars straight from <a href="http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/calendar/calendars/">here</a>.  Here is the list:</p>
<ul>
<li>calendar.all</li>
<li>calendar.birthday</li>
<li>calendar.canada</li>
<li>calendar.christian</li>
<li>calendar.computer</li>
<li>calendar.croatian</li>
<li>calendar.discord</li>
<li>calendar.fictional</li>
<li>calendar.french</li>
<li>calendar.german</li>
<li>calendar.history</li>
<li>calendar.holiday</li>
<li>calendar.judaic</li>
<li>calendar.music</li>
<li>calendar.openbsd</li>
<li>calendar.pagan</li>
<li>calendar.russian</li>
<li>calendar.space</li>
<li>calendar.ushistory</li>
<li>calendar.usholiday</li>
<li>calendar.world</li>
</ul>

<h2>Calendar Function Examples</h2>
<p>Illustrating the random color output.</p>
<p><img src="http://uploads.askapache.com/2013/05/linux-calendar-examples.png" alt="Show Events that Occurred on this day in the Past" width="447" height="588" title="linux calendar examples" /></p>



<h2>Source Code for Calendar Function</h2>
<p>Download <a href="http://uploads.askapache.com/2013/05/askapache_calendar.txt">askapache_calendar.sh</a></p>
<pre>
#!/bin/bash
# Updated: Thu May 16 21:07:54 2013
# @ http://www.askapache.com/linux/show-events-occurred-day-linux.html
# Copyright (C) 2013 Free Software Foundation, Inc.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
&nbsp;
function askapache_calendar ()
{
&nbsp;
   if [[ ! -d ~/.calendar ]]; then
          echo "INSTALLING CALENDARS TO ~/.calendar";
&nbsp;
          local U=http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/calendar/calendars/ OPWD=$PWD;
&nbsp;
          mkdir -pv ~/.calendar;
&nbsp;
          cd ~/.calendar
          curl -# $(for f in $(curl -sSo - $U | sed &#039;/"&gt;calendar\./!d; s,^.*;&lt;a href="\./\([^"]\+\)".*$,\1,g&#039;); do echo -n " -O $U$f"; done);
          cd $OPWD
&nbsp;
          echo "CALENDARS INSTALLED";
   fi
&nbsp;
   local COLOR=$( echo -en $(( $RANDOM % ${1:-$RANDOM} + 1 )) );
&nbsp;
   echo -en "`tput setaf $COLOR`";
   sed -n "/$(date +%m\\/%d\\\|%b\*\ %d)/p" ~/.calendar/c*
   echo -en "`tput sgr0`"
}
</pre>
<p><a rel="follow" href="http://www.askapache.com/linux/show-events-occurred-day-linux.html"></a> &hellip;<a href="http://www.askapache.com/linux/show-events-occurred-day-linux.html">Show Events that Occurred on this day in the Past</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/linux/show-events-occurred-day-linux.html">Show Events that Occurred on this day in the Past</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/gsxi7n4v774" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/show-events-occurred-day-linux.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/linux/show-events-occurred-day-linux.html</feedburner:origLink></item>
		<item>
		<title>Bash alternative to Reflector for Ranking Mirrors</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/grvp9ols-mc/reflector-ranking-mirrors.html</link>
		<comments>http://www.askapache.com/shellscript/reflector-ranking-mirrors.html#comments</comments>
		<pubDate>Tue, 07 May 2013 06:20:31 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[ArchLinux]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[reflector]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[shell-script]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8892</guid>
		<description><![CDATA[<p><p><a class="IFL" href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html"><img src="http://uploads.askapache.com/2013/05/reflector-alternative-mirrorlist-300x217.png" alt="reflector-alternative-mirrorlist" width="300" height="217" /></a>A pure bash alternative to the python reflector, using curl, xargs, and sort for ranking Arch Linux mirrors.<br /><br />Nice and simple.  Short and sweet.<br class="C" /></p></p><p>The post <a href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html">Bash alternative to Reflector for Ranking Mirrors</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html"></a><a href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html"><cite>AskApache.com</cite></a></p><p>So if you don't already know, I am a long-time user and supporter of <a href="https://www.archlinux.org/">Arch Linux</a>.  Arch uses a package management tool called <strong>pacman</strong> that works similarly to yum or apt, but much better IMHO.  It uses a list of mirrors to perform the actual downloading of the package files, so you want the fastest mirrors to be in the mirror list.  The old way is to use reflector to rank the speed of the mirrors, which is a python script.  My way is pure bash using curl, sed, awk, xargs, and sort.  Very simple and IMHO more effective than reflector.</p>

<h2>Creating /etc/pacman.d/mirrorlist</h2>
<p>Just run the script and redirect the output to /etc/pacman.d/mirrorlist like this:</p>
<pre>$ ./reflector.sh | sudo tee /etc/pacman.d/mirrorlist</pre>
<p><a href="http://uploads.askapache.com/2013/05/reflector-alternative-mirrorlist.png"><img class="alignnone size-full wp-image-8895" alt="Bash alternative to Reflector for Ranking Mirrors" src="http://uploads.askapache.com/2013/05/reflector-alternative-mirrorlist.png" width="467" height="339" title="reflector alternative mirrorlist" /></a></p>

<h2>How it works</h2>
<p>Well it's simple, essentially it performs these steps:</p>
<ol>
<li>Fetch the current list of (only current 100%) mirrors from the official site.</li>
<li>Use curl to request a small 257 byte file from each of those mirrors (about 200-300), 40 at a time and save the fastest 50. <em>This also gets the dns cached for the next step</em></li>
<li>Use curl to request a 100 kb file from each of those mirrors, measuring the total time of the request, and the speed of the download, 10 at a time.</li>
<li>Finally, merge the results of both of those tests into a list of 50 mirrors in the format for outputting directly to <code>/etc/pacman.d/mirrorlist</code></li>
</ol>

<h2>Why pure bash over reflector?</h2>
<p>Well because I like my systems extra crazy lean, I often don't want to install python right after an initial install of Arch.  Also, this is much faster and easier on the system resources, and I believe it is also more accurate.  I'd like to encourage others to turn to pure shell scripting to do simple tasks like this, often that is a better long-term solution than building a new piece of software.  But I'm not against reflector, it's a pretty awesome bit of python with many features.</p>

<h2>reflector.sh Source</h2>
<p>Download <a href="http://uploads.askapache.com/2013/05/reflector.txt">reflector.sh</a></p>
<pre>#!/bin/bash
# Updated: Tues May 07 21:04:12 2013 by webmaster@askapache
# @ http://www.askapache.com/shellscript/reflector-ranking-mirrors.html
# Copyright (C) 2013 Free Software Foundation, Inc.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
&nbsp;
# if mirrors exists, cat it, otherwise create it
function get_mirrors () #{{{1
{
   if [[ -s $MIRRORS ]]; then
          cat $MIRRORS;
   else
          curl -LksS -o - &#039;https://www.archlinux.org/mirrors/status/json/&#039; | \
          sed &#039;s,{,\n{,g&#039; | sed -n &#039;/rsync/d; /pct": 1.0/p&#039; | sed &#039;s,^.*"url": "\([^"]\+\)".*,\1,g&#039; &gt; $MIRRORS
          cat $MIRRORS;
   fi
}
&nbsp;
function get_core_urls () #{{{1
{
   get_mirrors | sed "s,$,core/os/${ARCH}/core.db.tar.gz,g"
}
&nbsp;
function get_gcc_urls () #{{{1
{
   get_mirrors | sed "s,$,core/os/${ARCH}/${GCC_URL},g"
}
&nbsp;
# rm tmp file on exit
trap "exitcode=\$?; (rm -f \$MIRRORS 2&gt;/dev/null;) &amp;&amp; exit \$exitcode" 0;
trap "exit 1" 1 2 13 15;
&nbsp;
# file containing mirror urls
MIRRORS=`(mktemp -t reflector-mirrorsXXXX) 2&gt;/dev/null` &amp;&amp; test -w "$MIRRORS" || MIRRORS=~/reflector.mirrorsXXX
&nbsp;
# arch
ARCH=`(uname -m) 2&gt;/dev/null` || ARCH=x86_64
&nbsp;
# the gcc file
GCC_URL=$( curl -LksSH --url ftp://ftp.archlinux.org/core/os/${ARCH}/ 2&gt;/dev/null | sed -n &#039;s/^.*\ \(gcc-[0-9]\+.*.tar.xz.sig\)\ -.*$/\1/gp&#039; );
&nbsp;
{
   # faster as primarily used to pre-resolve dns for 2nd core test
   get_gcc_urls | xargs -I&#039;{}&#039; -P40 curl -Lks -o /dev/null -m 3 --retry 0 --no-keepalive -w &#039;%{time_total}@%{speed_download}@%{url_effective}\n&#039; --url &#039;{}&#039; |\
   sort -t@ -k2 -nr | head -n 50 | cut -d&#039;@&#039; -f3 | sed &#039;s,core/os/&#039;"${ARCH}/${GCC_URL}"&#039;,$repo/os/$arch,g&#039;
&nbsp;
   get_core_urls | xargs -I&#039;{}&#039; -P10 curl -Lks -o /dev/null -m 5 --retry 0 --no-keepalive -w &#039;%{time_total}@%{speed_download}@%{url_effective}\n&#039; --url &#039;{}&#039; |\
   sort -t@ -k2 -nr | head -n 50 | cut -d&#039;@&#039; -f3 | sed &#039;s,core/os/&#039;"${ARCH}"&#039;/core.db.tar.gz,$repo/os/$arch,g&#039;
} | sed &#039;s,^,Server = ,g&#039; | awk &#039;{ if (!h[$0]) { print $0; h[$0]=1 } }&#039;
&nbsp;
exit $?;</pre>




<h2>Xargs running curl in parallel</h2>
<p>Just shows the output of htop while running the script.</p>
<p><a href="http://uploads.askapache.com/2013/05/reflector-alternative.png"><img class="alignnone size-large wp-image-8893" alt="Bash alternative to Reflector for Ranking Mirrors" src="http://uploads.askapache.com/2013/05/reflector-alternative-1024x326.png" width="640" height="203" title="reflector alternative" /></a></p><p><a rel="follow" href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html"></a> &hellip;<a href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html">Bash alternative to Reflector for Ranking Mirrors</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/shellscript/reflector-ranking-mirrors.html">Bash alternative to Reflector for Ranking Mirrors</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/grvp9ols-mc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/shellscript/reflector-ranking-mirrors.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/shellscript/reflector-ranking-mirrors.html</feedburner:origLink></item>
		<item>
		<title>Htaccess – The Ultimate Guide</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/V3MucJTilfg/htaccess.html</link>
		<comments>http://www.askapache.com/htaccess/htaccess.html#comments</comments>
		<pubDate>Wed, 01 May 2013 13:05:32 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[301 Redirects]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[ErrorDocument]]></category>
		<category><![CDATA[File Permissions]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[mod_security]]></category>
		<category><![CDATA[mod_status]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[RedirectMatch]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[RewriteCond]]></category>
		<category><![CDATA[RewriteEngine]]></category>
		<category><![CDATA[RewriteRule]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/htaccesselite-ultimate-htaccess-article.html</guid>
		<description><![CDATA[<p><p>I discovered these tips and tricks mostly while working as a network security penetration specialist hired to find security holes in web hosting environments.   That is when I started examining htaccess files in great detail and learned about the incredible untapped power of htaccess.  The only avenue on shared-hosting was and is the .htaccess file, and holy freaking fiber-optics.. it's almost as powerful as httpd.conf itself</p></p><p>The post <a href="http://www.askapache.com/htaccess/htaccess.html">Htaccess &#8211; The Ultimate Guide</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/htaccess/htaccess.html"></a><a href="http://www.askapache.com/htaccess/htaccess.html"><cite>AskApache.com</cite></a></p><p><dfn title="HyperText Access">.htaccess</dfn> is a very ancient configuration file that controls the Web Server running your website, and is one of the most powerful configuration files you will ever come across. Htaccess has the ability to control access of the <acronym title="World Wide Web">WWW</acronym>'s HyperText Transfer Protocol (<acronym title="HyperText Transfer Protocol">HTTP</acronym>) using Password Protection, 301 Redirects, rewrites, and much much more.  This is because this configuration file was coded in the earliest days of the web (HTTP), for one of the first Web Servers ever!  Eventually these Web Servers (configured with htaccess) became known as the World Wide Web, and eventually grew into the Internet we use today.</p>
<p><a class="IFL" href="/htaccess/htaccess.html"><img src="http://uploads.askapache.com/2008/08/htaccess-up.png" alt=".htaccess file tutorial" title=".htaccess file tutorial" width="141" height="144" /></a>This is not an <em>introduction to .htaccess</em>&hellip; This is the evolution of the best of the best.<br /><br />You've come to the right place if you are looking to acquire <strong>mad skills</strong> for using .htaccess files.<br /><br />Originally (2003) this guide was known in certain hacker circles and hidden corners of the net as an <em>ultimate .htaccess</em> due to the powerful <strong>htaccess tricks</strong> and tips to bypass security on a webhost, and also because many of the tricks and <a href="#htaccess-code-examples">examples</a> were pretty impressive back then in that group.<br class="C" /></p>


<h2 class="htaccess" id="h21adf" style="font-weight:bold;">Htaccess - Evolved</h2>
<p>The Hyper Text Transfer Protocol (HTTP) was initiated at the CERN in Geneve (Switzerland), where it emerged (together with the HTML presentation language) from the need to exchange scientific information on a computer network in a simple manner. The first public HTTP implementation only allowed for plain text information, and almost instantaneously became a replacement of the GOPHER service. One of the first text-based browsers was LYNX which still exists today; a graphical HTTP client appeared very quickly with the name NCSA Mosaic. Mosaic was a popular browser back in 1994. Soon the need for a more rich multimedia experience was born, and the markup language provided support for a growing multitude of media types.</p>
<p>Htaccess file know-how will do several things for you:</p>
<ul><li>Make your website noticeably faster.</li><li>Allow you to debug your server with ease.</li><li>Make your life easier and more rewarding.</li><li>Allow you to work faster and more productively.</li></ul>


<h2>AskApache Htaccess Journey</h2>
<p><strong>Skip this - still under edit</strong></p>
<p>I discovered these tips and tricks mostly while working as a network security penetration specialist hired to find security holes in web hosting environments.  Shared hosting is the most common and cheapest form of web-hosting where multiple customers are placed on a single machine and "share" the resources (CPU/RAM/SPACE).  The machines are configured to basically ONLY do HTTP and FTP.  No shells or any interactive logins, no ssh, just FTP access.  That is when I started examining htaccess files in great detail and learned about the incredible untapped power of htaccess.  For 99% of the worlds best Apache admins, they don't use .htaccess much, if AT ALL.  It's much easier, safer, and faster to configure Apache using the httpd.conf file instead.  However, this file is almost never readable on shared-hosts, and I've never seen it writable.  So the only avenue left for those on shared-hosting was and is the .htaccess file, and holy freaking fiber-optics.. it's almost as powerful as httpd.conf itself!<br /><br />Most all .htaccess code works in the httpd.conf file, but not all httpd.conf code works in .htaccess files, around 50%.  So all the best Apache admins and programmers never used .htaccess files.  There was no incentive for those with access to httpd.conf to use htaccess, and the gap grew.  It's common to see "computer gurus" on forums and mailing lists rail against all uses and users of .htaccess files, smugly announcing the well known problems with .htaccess files compared with httpd.conf - I wonder if these "gurus" know the history of the htaccess file, like it's use in the earliest versions of the HTTP Server- NCSA's HTTPd, which BTW, became known as Apache HTTP.  So you could easily say that htaccess files predates Apache itself.<br /><br />Once I discovered what .htaccess files could do towards helping me enumerate and exploit security vulnerabilities even on big shared-hosts I focused all my research into .htaccess files, meaning I was reading the venerable Apache HTTP Source code 24/7!  I compiled every released version of the Apache Web Server, ever, even NCSA's, and focused on enumerating the most powerful htaccess directives. Good times! Because my focus was on protocol/file/network vulnerabilites instead of web dev I built up a nice toolbox of htaccess tricks to do unusual things.  When I switched over to webdev in 2005 I started using htaccess for websites, not research.  I documented most of my favorites and rewrote the htaccess guide for webdevelopers.  After some great encouragement on various forums and nets I decided to start a blog to share my work with everyone, AskApache.com was registered, I published my guide, and it was quickly plagiarized and scraped all over the net.  Information is freedom, and freedom is information, so this blog has the least restrictive copyright for you.  Feel free to modify, copy, republish, sell, or use anything on this site ;)</p>

<h2>What Is .htaccess</h2>
<p>Specifically, <kbd>.htaccess</kbd> is the default file name of a special configuration file that provides a number of <a href="#htaccess-directives">directives</a> (commands) for controlling and configuring the <a href="http://httpd.apache.org/" title="open-source HTTP server running the WWW">Apache Web Server</a>, and also to control and configure <a href="#htaccess-modules">modules</a> that can be built into the Apache installation, or included at run-time like mod_rewrite (for htaccess rewrite), mod_alias (for htaccess redirects), and mod_ssl (for controlling SSL connections).</p>
<p><strong>Htaccess</strong> allows for decentralized management of Web Server configurations which makes life very easy for web hosting companies and especially their savvy consumers.  They set up and run "server farms" where many hundreds and thousands of web hosting customers are all put on the same Apache Server.  This type of hosting is called "virtual hosting" and without .htaccess files would mean that every customer must use the same exact settings as everyone else on their segment.  So that is why any half-decent web host allows/enables <em>(DreamHost, Powweb, MediaTemple, GoDaddy) .htaccess files</em>, though few people are aware of it.  Let's just say that if I was a customer on your server-farm, and .htaccess files were enabled, my websites would be a LOT faster than yours, as these configuration files allow you to fully take advantage of and utilize the resources allotted to you by your host.  If even 1/10 of the sites on a server-farm took advantage of what they are paying for, the providers would go out of business.</p>

<blockquote cite="http://httpd.apache.org/docs/1.3/misc/API.html">
<p><strong>SKIP: </strong>History of Htaccess in 1st Apache.<br /><br />One of the design goals for this server was to maintain external compatibility with the NCSA 1.3 server --- that is, to read the same configuration files, to process all the directives therein correctly, and in general to be a drop-in replacement for NCSA. On the other hand, another design goal was to move as much of the server's functionality into modules which have as little as possible to do with the monolithic server core. The only way to reconcile these goals is to move the handling of most commands from the central server into the modules.</p>
<p>However, just giving the modules command tables is not enough to divorce them completely from the server core. The server has to remember the commands in order to act on them later. That involves maintaining data which is private to the modules, and which can be either per-server, or per-directory. Most things are per-directory, including in particular access control and authorization information, but also information on how to determine file types from suffixes, which can be modified by AddType and DefaultType directives, and so forth. In general, the governing philosophy is that anything which can be made configurable by directory should be; per-server information is generally used in the standard set of modules for information like Aliases and Redirects which come into play before the request is tied to a particular place in the underlying file system.</p>
<p>Another requirement for emulating the NCSA server is being able to handle the <strong>per-directory configuration files, generally called .htaccess files</strong>, though even in the NCSA server they can contain directives which have nothing at all to do with access control. Accordingly, after URI -> filename translation, but before performing any other phase, the server walks down the directory hierarchy of the underlying filesystem, following the translated pathname, to read any .htaccess files which might be present. The information which is read in then has to be merged with the applicable information from the server's own config files (either from the <code>&lt;directory&gt;</code> sections in access.conf, or from defaults in srm.conf, which actually behaves for most purposes almost exactly like <code>&lt;directory /&gt;</code>).</p>
<p>Finally, after having served a request which involved <strong>reading .htaccess files</strong>, we need to discard the storage allocated for handling them. That is solved the same way it is solved wherever else similar problems come up, by tying those structures to the per-transaction resource pool.</p>
</blockquote>


<h4 class="tic">Creating Htaccess Files</h4>
<p><a class="IFL" href="http://uploads.askapache.com/2009/01/htaccess-explorer.png"><img src="http://uploads.askapache.com/2009/01/htaccess-explorer.png" alt="What an Htaccess File Looks Like in Windows Explorer" title="What an Htaccess File Looks Like in Windows Explorer" width="243" height="322" /></a>Htaccess files use the default filename "<code>.htaccess</code>" but any unix-style file name can be specified from the <a href="#httpd-config-examples">main server config</a> using the <code>AccessFileName</code> directive.  The file isn't <code>.htaccess.txt</code>, its literally just named <code>.htaccess</code>.<br class="C" /></p>
<p><a class="IFR" href="http://uploads.askapache.com/2009/01/viewing-htaccess-files.png"><img src="http://uploads.askapache.com/2009/01/viewing-htaccess-files.png" alt="View .htaccess files" title="View .htaccess files" width="386" height="287" /></a>In a Windows Environment like the one I use for work, you can change how Windows opens and views .htaccess files by modifying the Folder Options in explorer.  As you can see, on my computer files ending in .htaccess are recognized as having the HTACCESS extension and are handled/opened by Adobe Dreamweaver CS4.<br class="C" /></p>

<h4>Htaccess Scope</h4>
<p>Unlike the main server configuration files like <a href="#httpd-config-examples">httpd.conf</a>, <strong>Htaccess files are read on every request</strong> therefore changes in these files take immediate effect.  Apache searches all directories and subdirectories that are htaccess-enabled for an .htaccess file which results in performance loss due to file accesses. I've never noticed a performance loss but OTOH, I know how to use them.  If you do have access to your main server configuration file, you should of course use that instead, and lucky for you ALL the .htaccess tricks and examples can be used there as well (just not vice versa).</p>


<h3>Htaccess File Syntax</h3>
<p>Htaccess files follow the same syntax as the main Apache configuration files, for powerusers here's an <a href='http://uploads.askapache.com/2009/01/apache.vim'>apache.vim</a> for VI. The one main difference is the <dfn title="Whether the directive is allowed in .htaccess files">context</dfn> of the directive, which means whether or not that directive is ALLOWED to be used inside of an .htaccess file.  Htaccess files are incredibly powerful, and can also be very dangerous as some directives allowed in the main configuration files would allow users/customers to completely bypass security/bandwidth-limits/resource-limits/file-permissions, etc..  About 1/4 of all Apache directives cannot be used inside an .htaccess file (also known as a per-directory context config).  The Apache Developers are well-regarded throughout the world as being among some of the best programmers, ever.  To enable a disallowed directive inside a .htaccess file would require modifying the source code and re-compiling the server (which they allow and encourage if you are the owner/admin).</p>

<h3>Htaccess Directives</h3>
<p><strong>Don't ask why</strong>, but I personally downloaded each major/beta release of the Apache HTTPD source code from version 1.3.0 to version 2.2.10 (<dfn title="1.3.0, 1.3.1, 1.3.11, 1.3.12, 1.3.14, 1.3.17, 1.3.19, 1.3.2, 1.3.20, 1.3.22, 1.3.23, 1.3.24, 1.3.27, 1.3.28, 1.3.29, 1.3.3, 1.3.31, 1.3.32, 1.3.33, 1.3.34, 1.3.35, 1.3.36, 1.3.37, 1.3.39, 1.3.4, 1.3.41, 1.3.6, 1.3.9, 2.0.35, 2.0.36, 2.0.39, 2.0.40, 2.0.42, 2.0.43, 2.0.44, 2.0.45, 2.0.46, 2.0.47, 2.0.48, 2.0.49, 2.0.50, 2.0.51, 2.0.52, 2.0.53, 2.0.54, 2.0.55, 2.0.58, 2.0.59, 2.0.61, 2.0.63, 2.1.3-beta, 2.1.6-alpha, 2.1.7-beta, 2.1.8-beta, 2.1.9-beta, 2.2.0, 2.2.2, 2.2.3, 2.2.4, 2.2.6, 2.2.8, 2.2.9, 2.2.10">all 63 Apache versions</dfn>!), then I <strong>configured and compiled each version for a custom HTTPD installation built from source</strong>. This allowed me to find <strong><a href="#htaccess-directives-list">every directive allowed in .htaccess files</a></strong> for each particular version, which has never been done before, or since. <strong>YES!</strong> <em>I think that is so cool..</em></p>
<p><strong>An .htaccess directive</strong> is basically a command that is specific to a module or builtin to the core that performs a specific task or sets a specific setting for how Apache serves your WebSite.  Directives placed in Htaccess files <strong>apply to the directory they are in, and all sub-directories</strong>.  Here's the 3 top links (<em>official Apache Docs</em>) you will repeatedly use, bookmark/print/save them.</p>
<p><a href="http://uploads.askapache.com/2008/08/htaccess-up1.png"><img src="http://uploads.askapache.com/2008/08/htaccess-up1-350x178.png" alt="htaccess Context Legend" title="htaccess-up1" width="350" height="178" /></a></p>
<ol><li><a href="http://httpd.apache.org/docs/trunk/mod/directive-dict.html">Terms Used to Describe Directives</a></li><li><a href="http://httpd.apache.org/docs/trunk/mod/directives.html">Official List of Apache Directives</a></li><li><a href="http://httpd.apache.org/docs/trunk/mod/quickreference.html">Directive Quick-Reference -- with Context</a></li></ol>
<hr class="C" />








<h2>Main Server Config Examples</h2>
<p>Now lets take a look at some htaccess examples to get a feel for the syntax and some general ideas at the capabilities.  Some of the best examples for .htaccess files are included with Apache for <a href="http://httpd.apache.org/docs/trunk/configuring.html">main server config</a> files, so lets take a quick look at a couple of them on our way down to the actual .htaccess examples further down the page (this site has thousands, take your time).  The basic syntax is <strong>a line starting with # is a comment, everything else are directives followed by the directive argument</strong>.</p>
<p><strong><a href="http://uploads.askapache.com/2008/08/httpd-multilang-errordocconf.in">httpd-multilang-errordoc.conf</a></strong>: The configuration below implements multi-language error documents through content-negotiation</p>

<p>Here are the rest of them if you wanna take a look.  (<a href="http://uploads.askapache.com/2008/08/httpd-mpmconf.in" title="Server-Pool Management (MPM specific)">httpd-mpm.conf</a>, <a href="http://uploads.askapache.com/2008/08/httpd-defaultconf.in" title="This configuration file reflects default settings for Apache HTTP Server">httpd-default.conf</a>, <a href="http://uploads.askapache.com/2008/08/httpd-sslconf.in" title="Contains the configuration directives to instruct the server how to serve pages over an https connection">httpd-ssl.conf</a>, <a href="http://uploads.askapache.com/2008/08/httpd-infoconf.in" title="Get information about the requests being processed by the server and the configuration of the server">httpd-info.conf</a>, <a href="http://uploads.askapache.com/2008/08/httpd-vhostsconf.in" title="If you want to maintain multiple domains/hostnames on your machine">httpd-vhosts.conf</a>, <a href="http://uploads.askapache.com/2008/08/httpd-davconf.in" title="Distributed authoring and versioning (WebDAV)">httpd-dav.conf</a>)</p>
<hr class="C" />










<h2>Example .htaccess Code Snippets</h2>
<p>Here are some specific examples, this is the most popular section of this page.  Updated frequently.</p>

<h4>Redirect Everyone Except IP address to alternate page</h4>
<pre>ErrorDocument 403 http://www.yahoo.com/
Order deny,allow
Deny from all
Allow from 208.113.134.190</pre>

<h4>When developing sites</h4>
<p>This lets google crawl the page, lets me access  without a password, and lets my client access the page WITH a password.  It also allows for XHTML and CSS validation! (w3.org)</p>
<pre>AuthName "Under Development"
AuthUserFile /home/sitename.com/.htpasswd
AuthType basic
Require valid-user
Order deny,allow
Deny from all
Allow from 208.113.134.190 w3.org htmlhelp.com googlebot.com
Satisfy Any</pre>

<h4>Fix double-login prompt</h4>
<p>Redirect non-https requests to https server and ensure that <strong>.htpasswd authorization</strong> can only be entered across HTTPS</p>
<pre>SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "askapache.com"
ErrorDocument 403 https://askapache.com</pre>

<h4>Set Timezone of the Server (GMT)</h4>
<pre class='anting'>SetEnv TZ America/Indianapolis</pre>

<h4>Administrator Email for ErrorDocument</h4>
<pre>SetEnv SERVER_ADMIN webmaster@google.com</pre>

<h4><code>ServerSignature</code> for <code>ErrorDocument</code></h4>
<pre>ServerSignature off | on | email</pre>

<h4>Charset and Language headers</h4>
<p>Article: <a href="/htaccess/setting-charset-in-htaccess.html">Setting Charset in htaccess</a>, and <a href="http://www.w3.org/International/questions/qa-htaccess-charset">article by <cite>Richard Ishida</cite></a></p>
<pre>AddDefaultCharset UTF-8
DefaultLanguage en-US</pre>

<h4>Disallow Script Execution</h4>
<pre>Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi</pre>

<h4>Deny Request Methods</h4>
<pre>RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|OPTIONS|POST|PUT)
RewriteRule .* - [F]</pre>

<h4>Force "File Save As" Prompt</h4>
<pre>AddType application/octet-stream .avi .mpg .mov .pdf .xls .mp4</pre>

<h4>Show CGI Source Code</h4>
<pre>RemoveHandler cgi-script .pl .py .cgi
AddType text/plain .pl .py .cgi</pre>

<h4>Serve all .pdf files on your site using .htaccess and mod_rewrite with the php script.</h4>
<pre>RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+)\.pdf$  /cgi-bin/pdf.php?file=$1 [L,NC,QSA]</pre>

<h4>Rewrite to www</h4>
<pre>RewriteCond %{REQUEST_URI} !^/(robots\.txt|favicon\.ico|sitemap\.xml)$
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]</pre>

<h4>Rewrite to www dynamically</h4>
<pre>RewriteCond %{REQUEST_URI} !^/robots\.txt$ [NC]
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$   [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]</pre>

<h4>301 Redirect Old File</h4>
<pre>Redirect 301 /old/file.html http://www.askapache.com/new/file.html</pre>

<h4>301 Redirect Entire Directory</h4>
<pre>RedirectMatch 301 /blog(.*) http://www.askapache.com/$1</pre>

<h4>Protecting your php.cgi</h4>
<pre>&lt;FilesMatch "^php5?\.(ini|cgi)$"&gt;
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
&lt;/FilesMatch&gt;</pre>

<h4>Set Cookie based on Request</h4>
<p>This code sends the <code>Set-Cookie</code> header to create a cookie on the client with the value of a matching item in 2nd parantheses.</p>
<pre>RewriteEngine On
RewriteBase /
RewriteRule ^(.*)(de|es|fr|it|ja|ru|en)/$ - [co=lang:$2:.askapache.com:7200:/]</pre>


<h4>Set Cookie with env variable</h4>
<pre>Header set Set-Cookie "language=%{lang}e; path=/;" env=lang</pre>

<h4>Custom ErrorDocuments</h4>
<pre>ErrorDocument 100 /100_CONTINUE
ErrorDocument 101 /101_SWITCHING_PROTOCOLS
ErrorDocument 102 /102_PROCESSING
ErrorDocument 200 /200_OK
ErrorDocument 201 /201_CREATED
ErrorDocument 202 /202_ACCEPTED
ErrorDocument 203 /203_NON_AUTHORITATIVE
ErrorDocument 204 /204_NO_CONTENT
ErrorDocument 205 /205_RESET_CONTENT
ErrorDocument 206 /206_PARTIAL_CONTENT
ErrorDocument 207 /207_MULTI_STATUS
ErrorDocument 300 /300_MULTIPLE_CHOICES
ErrorDocument 301 /301_MOVED_PERMANENTLY
ErrorDocument 302 /302_MOVED_TEMPORARILY
ErrorDocument 303 /303_SEE_OTHER
ErrorDocument 304 /304_NOT_MODIFIED
ErrorDocument 305 /305_USE_PROXY
ErrorDocument 307 /307_TEMPORARY_REDIRECT
ErrorDocument 400 /400_BAD_REQUEST
ErrorDocument 401 /401_UNAUTHORIZED
ErrorDocument 402 /402_PAYMENT_REQUIRED
ErrorDocument 403 /403_FORBIDDEN
ErrorDocument 404 /404_NOT_FOUND
&nbsp;
ErrorDocument 405 /405_METHOD_NOT_ALLOWED
ErrorDocument 406 /406_NOT_ACCEPTABLE
ErrorDocument 407 /407_PROXY_AUTHENTICATION_REQUIRED
ErrorDocument 408 /408_REQUEST_TIME_OUT
ErrorDocument 409 /409_CONFLICT
ErrorDocument 410 /410_GONE
ErrorDocument 411 /411_LENGTH_REQUIRED
ErrorDocument 412 /412_PRECONDITION_FAILED
ErrorDocument 413 /413_REQUEST_ENTITY_TOO_LARGE
ErrorDocument 414 /414_REQUEST_URI_TOO_LARGE
ErrorDocument 415 /415_UNSUPPORTED_MEDIA_TYPE
ErrorDocument 416 /416_RANGE_NOT_SATISFIABLE
ErrorDocument 417 /417_EXPECTATION_FAILED
ErrorDocument 422 /422_UNPROCESSABLE_ENTITY
ErrorDocument 423 /423_LOCKED
ErrorDocument 424 /424_FAILED_DEPENDENCY
ErrorDocument 426 /426_UPGRADE_REQUIRED
ErrorDocument 500 /500_INTERNAL_SERVER_ERROR
ErrorDocument 501 /501_NOT_IMPLEMENTED
ErrorDocument 502 /502_BAD_GATEWAY
ErrorDocument 503 /503_SERVICE_UNAVAILABLE
ErrorDocument 504 /504_GATEWAY_TIME_OUT
ErrorDocument 505 /505_VERSION_NOT_SUPPORTED
ErrorDocument 506 /506_VARIANT_ALSO_VARIES
ErrorDocument 507 /507_INSUFFICIENT_STORAGE
ErrorDocument 510 /510_NOT_EXTENDED</pre>

<h4>Implementing a Caching Scheme with .htaccess</h4>
<pre># year
&lt;FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$"&gt;
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
&lt;/FilesMatch&gt;
#2 hours
&lt;FilesMatch "\.(html|htm|xml|txt|xsl)$"&gt;
Header set Cache-Control "max-age=7200, must-revalidate"
&lt;/FilesMatch&gt;
&lt;FilesMatch "\.(js|css)$"&gt;
SetOutputFilter DEFLATE
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
&lt;/FilesMatch&gt;</pre>

<h4>Password Protect single file</h4>
<pre>&lt;Files login.php&gt;
AuthName "Prompt"
AuthType Basic
AuthUserFile /web/askapache.com/.htpasswd
Require valid-user
&lt;/Files&gt;</pre>

<h4>Password Protect multiple files</h4>
<pre>&lt;FilesMatch "^(private|phpinfo).*$"&gt;
AuthName "Development"
AuthUserFile /.htpasswd
AuthType basic
Require valid-user
&lt;/FilesMatch&gt;</pre>

<h4>Send Custom Headers</h4>
<pre>Header set P3P "policyref="http://www.askapache.com/w3c/p3p.xml""
Header set X-Pingback "http://www.askapache.com/xmlrpc.php"
Header set Content-Language "en-US"
Header set Vary "Accept-Encoding"</pre>

<h4>Blocking based on User-Agent Header</h4>
<pre>SetEnvIfNoCase ^User-Agent$ .*(craftbot|download|extract|stripper|sucker|ninja|clshttp|webspider|leacher|collector|grabber|webpictures) HTTP_SAFE_BADBOT
SetEnvIfNoCase ^User-Agent$ .*(libwww-perl|aesop_com_spiderman) HTTP_SAFE_BADBOT
Deny from env=HTTP_SAFE_BADBOT</pre>

<h4>Blocking with RewriteCond</h4>
<pre>RewriteCond %{HTTP_USER_AGENT} ^.*(craftbot|download|extract|stripper|sucker|ninja|clshttp|webspider|leacher|collector|grabber|webpictures).*$ [NC]
RewriteRule . - [F,L]</pre>

<h4>.htaccess for mod_php</h4>
<pre>SetEnv PHPRC /location/todir/containing/phpinifile</pre>

<h4>.htaccess for php as cgi</h4>
<pre>AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php5.cgi</pre>

<h4>Shell wrapper for custom php.ini</h4>
<pre>#!/bin/sh
export PHP_FCGI_CHILDREN=3
exec php5.cgi -c /abs/php5/php.ini</pre>

<h4>Add values from HTTP Headers</h4>
<pre>SetEnvIfNoCase ^If-Modified-Since$ "(.+)" HTTP_IF_MODIFIED_SINCE=$1
SetEnvIfNoCase ^If-None-Match$ "(.+)" HTTP_IF_NONE_MATCH=$1
SetEnvIfNoCase ^Cache-Control$ "(.+)" HTTP_CACHE_CONTROL=$1
SetEnvIfNoCase ^Connection$ "(.+)" HTTP_CONNECTION=$1
SetEnvIfNoCase ^Keep-Alive$ "(.+)" HTTP_KEEP_ALIVE=$1
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
SetEnvIfNoCase ^Cookie$ "(.+)" HTTP_MY_COOKIE=$1</pre>

<h4>Stop hotlinking</h4>
<pre>RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache\.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/feed.gif [R=302,L]</pre>

<h4>Turn logging off for IP</h4>
<pre>SecFilterSelective REMOTE_ADDR "208\.113\.183\.103" "nolog,noauditlog,pass"</pre>

<h4>Turn logging on for IP</h4>
<pre>SecFilterSelective REMOTE_ADDR "!^208\.113\.183\.103" "nolog,noauditlog,pass"
SecFilterSelective REMOTE_ADDR "208\.113\.183\.103" "log,auditlog,pass"</pre>
<hr class="C" />




<h2>Example .htaccess Files</h2>
<p>Here are some samples and examples taken from different .htaccess files I've used over the years.  Specific solutions are farther down on this page and throughout the site.</p>
<pre># Set the Time Zone of your Server
SetEnv TZ America/Indianapolis
&nbsp;
# ServerAdmin:  This address appears on some server-generated pages, such as error documents.
SetEnv SERVER_ADMIN webmaster@askapache.com
&nbsp;
# Possible values for the Options directive are "None", "All", or any combination of:
#  Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
Options -ExecCGI -MultiViews -Includes -Indexes FollowSymLinks
&nbsp;
# DirectoryIndex: sets the file that Apache will serve if a directory is requested.
DirectoryIndex index.html index.php /index.php
&nbsp;
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#
Action php5-cgi /bin/php.cgi
&nbsp;
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler php-cgi .php .inc
&nbsp;
# Commonly used filename extensions to character sets.
AddDefaultCharset UTF-8
&nbsp;
# AddType allows you to add to or override the MIME configuration
AddType &#039;application/rdf+xml; charset=UTF-8&#039; .rdf
AddType &#039;application/xhtml+xml; charset=UTF-8&#039; .xhtml
AddType &#039;application/xhtml+xml; charset=UTF-8&#039; .xhtml.gz
AddType &#039;text/html; charset=UTF-8&#039; .html
AddType &#039;text/html; charset=UTF-8&#039; .html.gz
AddType application/octet-stream .rar .chm .bz2 .tgz .msi .pdf .exe
AddType application/vnd.ms-excel .csv
AddType application/x-httpd-php-source .phps
AddType application/x-pilot .prc .pdb
AddType application/x-shockwave-flash .swf
AddType application/xrds+xml .xrdf
AddType text/plain .ini .sh .bsh .bash .awk .nawk .gawk .csh .var .c .in .h .asc .md5 .sha .sha1
AddType video/x-flv .flv
&nbsp;
# AddEncoding allows you to have certain browsers uncompress information on the fly. Note: Not all browsers support this.
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
&nbsp;
# DefaultType: the default MIME type the server will use for a document.
DefaultType text/html
&nbsp;
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
ServerSignature Off</pre>


<pre>## MAIN DEFAULTS
Options +ExecCGI -Indexes
DirectoryIndex index.html index.htm index.php
DefaultLanguage en-US
AddDefaultCharset UTF-8
ServerSignature Off
&nbsp;
## ENVIRONMENT VARIABLES
SetEnv PHPRC /webroot/includes
SetEnv TZ America/Indianapolis
&nbsp;
SetEnv SERVER_ADMIN webmaster@askapache.com
&nbsp;
## MIME TYPES
AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf
AddType image/x-icon .ico
&nbsp;
## FORCE FILE TO DOWNLOAD INSTEAD OF APPEAR IN BROWSER
# http://www.htaccesselite.com/addtype-addhandler-action-vf6.html
AddType application/octet-stream .mov .mp3 .zip
&nbsp;
## ERRORDOCUMENTS
# http://askapache.com/htaccess/apache-status-code-headers-errordocument.html
ErrorDocument 400 /e400/
ErrorDocument 401 /e401/
ErrorDocument 402 /e402/
ErrorDocument 403 /e403/
ErrorDocument 404 /e404/
&nbsp;
# Handlers be builtin, included in a module, or added with Action directive
# default-handler: default, handles static content (core)
#   send-as-is: Send file with HTTP headers (mod_asis)
#   cgi-script: treat file as CGI script (mod_cgi)
#    imap-file: Parse as an imagemap rule file (mod_imap)
#   server-info: Get server config info (mod_info)
#  server-status: Get server status report (mod_status)
#    type-map: type map file for content negotiation (mod_negotiation)
#  fastcgi-script: treat file as fastcgi script (mod_fastcgi)
#
# http://www.askapache.com/php/custom-phpini-tips-and-tricks.html
&nbsp;
## PARSE AS CGI
AddHandler cgi-script .cgi .pl .spl
&nbsp;
## RUN PHP AS APACHE MODULE
AddHandler application/x-httpd-php .php .htm
&nbsp;
## RUN PHP AS CGI
AddHandler php-cgi .php .htm
&nbsp;
## CGI PHP WRAPPER FOR CUSTOM PHP.INI
AddHandler phpini-cgi .php .htm
Action phpini-cgi /cgi-bin/php5-custom-ini.cgi
&nbsp;
## FAST-CGI SETUP WITH PHP-CGI WRAPPER FOR CUSTOM PHP.INI
AddHandler fastcgi-script .fcgi
AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php5-wrapper.fcgi
&nbsp;
## CUSTOM PHP CGI BINARY SETUP
AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php.cgi
&nbsp;
## PROCESS SPECIFIC FILETYPES WITH CGI-SCRIPT
Action image/gif /cgi-bin/img-create.cgi
&nbsp;
## CREATE CUSTOM HANDLER FOR SPECIFIC FILE EXTENSIONS
AddHandler custom-processor .ssp
Action custom-processor /cgi-bin/myprocessor.cgi
&nbsp;
### HEADER CACHING
# http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html
&lt;FilesMatch "\.(flv|gif|jpg|jpeg|png|ico)$"&gt;
Header set Cache-Control "max-age=2592000"
&lt;/FilesMatch&gt;
&lt;FilesMatch "\.(js|css|pdf|swf)$"&gt;
Header set Cache-Control "max-age=604800"
&lt;/FilesMatch&gt;
&lt;FilesMatch "\.(html|htm|txt)$"&gt;
Header set Cache-Control "max-age=600"
&lt;/FilesMatch&gt;
&lt;FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"&gt;
Header unset Cache-Control
&lt;/FilesMatch&gt;
&nbsp;
## ALTERNATE EXPIRES CACHING
# htaccesselite.com/d/use-htaccess-to-speed-up-your-site-discussion-vt67.html
ExpiresActive On
ExpiresDefault A604800
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType text/html A300
&nbsp;
&lt;FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"&gt;
ExpiresActive Off
&lt;/FilesMatch&gt;
&nbsp;
## META HTTP-EQUIV REPLACEMENTS
&lt;FilesMatch "\.(html|htm|php)$"&gt;
Header set imagetoolbar "no"
&lt;/FilesMatch&gt;</pre>

<p>Here are some default MOD_REWRITE code examples.</p>
<pre>## REWRITE DEFAULTS
RewriteEngine On
RewriteBase /
&nbsp;
## REQUIRE SUBDOMAIN
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^subdomain\.askapache\.com$ [NC]
RewriteRule ^/(.*)$ http://subdomain.askapache.com/$1 [L,R=301]
&nbsp;
## SEO REWRITES
RewriteRule ^(.*)/ve/(.*)$ $1/voluntary-employee/$2 [L,R=301]
RewriteRule ^(.*)/hsa/(.*)$ $1/health-saving-account/$2 [L,R=301]
&nbsp;
## WORDPRESS
RewriteCond %{REQUEST_FILENAME} !-f  # Existing File
RewriteCond %{REQUEST_FILENAME} !-d  # Existing Directory
RewriteRule . /index.php [L]
&nbsp;
## ALTERNATIVE ANTI-HOTLINKING
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(subdomain\.)?askapache\.com/.*$ [NC]
RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ - [F]
&nbsp;
## REDIRECT HOTLINKERS
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(subdomain\.)?askapache\.com/.*$ [NC]
RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ http://google.com [R]
&nbsp;
## DENY REQUEST BASED ON REQUEST METHOD
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)$ [NC]
RewriteRule ^.*$ - [F]
&nbsp;
## REDIRECT UPLOADS
RewriteCond %{REQUEST_METHOD} ^(PUT|POST)$ [NC]
RewriteRule ^(.*)$ /cgi-bin/form-upload-processor.cgi?p=$1 [L,QSA]
&nbsp;
## REQUIRE SSL EVEN WHEN MOD_SSL IS NOT LOADED
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
&nbsp;
### ALTERNATATIVE TO USING ERRORDOCUMENT
# http://www.htaccesselite.com/d/htaccess-errordocument-examples-vt11.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /error.php [L]
&nbsp;
## SEO REDIRECTS
Redirect 301 /2006/oldfile.html http://subdomain.askapache.com/newfile.html
RedirectMatch 301 /o/(.*)$ http://subdomain.askapache.com/s/dl/$1
</pre>

<p>Examples of protecting your files and securing with password protection.</p>
<pre>#
# Require (user|group|valid-user) (username|groupname)
#
## BASIC PASSWORD PROTECTION
AuthType basic
AuthName "prompt"
AuthUserFile /.htpasswd
AuthGroupFile /dev/null
Require valid-user
&nbsp;
## ALLOW FROM IP OR VALID PASSWORD
Require valid-user
Allow from 192.168.1.23
Satisfy Any
&nbsp;
## PROTECT FILES
&lt;FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$"&gt;
Order Allow,Deny
Deny from all
&lt;/FilesMatch&gt;
&nbsp;
## PREVENT HOTLINKING
SetEnvIfNoCase Referer "^http://subdomain.askapache.com/" good
SetEnvIfNoCase Referer "^$" good
&lt;FilesMatch "\.(png|jpg|jpeg|gif|bmp|swf|flv)$"&gt;
Order Deny,Allow
Deny from all
Allow from env=good
ErrorDocument 403 http://www.google.com/intl/en_ALL/images/logo.gif
ErrorDocument 403 /images/you_bad_hotlinker.gif
&lt;/FilesMatch&gt;
&nbsp;
## LIMIT UPLOAD FILE SIZE TO PROTECT AGAINST DOS ATTACK
#bytes, 0-2147483647(2GB)
LimitRequestBody 10240000
&nbsp;
## MOST SECURE WAY TO REQUIRE SSL
# http://www.askapache.com/htaccess/apache-ssl-in-htaccess-examples.html
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "askapache.com"
ErrorDocument 403 https://askapache.com
&nbsp;
## COMBINED DEVELOPER HTACCESS CODE-USE THIS
&lt;FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|js|css|pdf|swf|html|htm|txt)$"&gt;
Header set Cache-Control "max-age=5"
&lt;/FilesMatch&gt;
AuthType basic
AuthName "Ooops! Temporarily Under Construction..."
AuthUserFile /.htpasswd
AuthGroupFile /dev/null
Require valid-user      # password prompt for everyone else
Order Deny,Allow
Deny from all
Allow from 192.168.64.5   # Your, the developers IP address
Allow from w3.org      # css/xhtml check jigsaw.w3.org/css-validator/
Allow from googlebot.com   # Allows google to crawl your pages
Satisfy Any        # no password required if host/ip is Allowed
&nbsp;
## DONT HAVE TO EMPTY CACHE OR RELOAD TO SEE CHANGES
ExpiresDefault A5 #If using mod_expires
&lt;FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|js|css|pdf|swf|html|htm|txt)$"&gt;
Header set Cache-Control "max-age=5"
&lt;/FilesMatch&gt;
&nbsp;
## ALLOW ACCESS WITH PASSWORD OR NO PASSWORD FOR SPECIFIC IP/HOSTS
AuthType basic
AuthName "Ooops! Temporarily Under Construction..."
AuthUserFile /.htpasswd
AuthGroupFile /dev/null
Require valid-user      # password prompt for everyone else
Order Deny,Allow
Deny from all
Allow from 192.168.64.5   # Your, the developers IP address
Allow from w3.org      # css/xhtml check jigsaw.w3.org/css-validator/
Allow from googlebot.com   # Allows google to crawl your pages
Satisfy Any        # no password required if host/ip is Allowed</pre>
<hr class="C" />





<h2>Advanced Mod_Rewrites</h2>
<p>Here are some <a href="http://www.askapache.com/htaccess/htaccess.html" title="Htaccess Tutorial">specific htaccess</a> examples taken mostly from my WordPress Password Protection plugin, which does alot more than password protection as you will see from the following mod_rewrite examples. These are a few of the mod_rewrite uses that BlogSecurity declared <strong>pushed the boundaries of Mod_Rewrite!</strong>  Some of these snippets are quite exotic and unlike anything you may have seen before, also only for those who understand them as they can kill a website pretty quick.</p>

<h3>Directory Protection</h3>
<p>Enable the DirectoryIndex Protection, preventing directory index listings and defaulting. [<a href="/htaccess/htaccess.html">Disable</a>]</p>
<pre>Options -Indexes
DirectoryIndex index.html index.php /index.php</pre>

<h3>Password Protect wp-login.php</h3>
<p>Requires a valid user/pass to access the login page[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-401">401</a>]</p>
<pre>&lt;Files wp-login.php&gt;
Order Deny,Allow
Deny from All
Satisfy Any
AuthName "Protected By AskApache"
AuthUserFile /web/askapache.com/.htpasswda1
AuthType Basic
Require valid-user
&lt;/Files&gt;</pre>


<h3>Password Protect wp-admin</h3>
<p>Requires a valid user/pass to access any non-static (css, js, images) file in this directory.[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-401">401</a>]</p>
<pre>Options -ExecCGI -Indexes +FollowSymLinks -Includes
DirectoryIndex index.php /index.php
Order Deny,Allow
Deny from All
Satisfy Any
AuthName "Protected By AskApache"
AuthUserFile /web/askapache.com/.htpasswda1
AuthType Basic
Require valid-user
&lt;FilesMatch "\.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$"&gt;
Allow from All
&lt;/FilesMatch&gt;
&lt;FilesMatch "(async-upload)\.php$"&gt;
&lt;IfModule mod_security.c&gt;
SecFilterEngine Off
&lt;/IfModule&gt;
Allow from All
&lt;/FilesMatch&gt;</pre>

<h3>Protect wp-content</h3>
<p>Denies any Direct request for files ending in .php with a 403 Forbidden.. May break plugins/themes [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-401">401</a>]</p>
<pre>RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /wp-content/.*$ [NC]
RewriteCond %{REQUEST_FILENAME} !^.+flexible-upload-wp25js.php$
RewriteCond %{REQUEST_FILENAME} ^.+\.(php|html|htm|txt)$
RewriteRule .* - [F,NS,L]</pre>

<h3>Protect wp-includes</h3>
<p>Denies any Direct request for files ending in .php with a 403 Forbidden.. May break plugins/themes [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /wp-includes/.*$ [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /wp-includes/js/.+/.+\ HTTP/ [NC]
RewriteCond %{REQUEST_FILENAME} ^.+\.php$
RewriteRule .* - [F,NS,L]</pre>

<h3>Common Exploits</h3>
<p>Block common exploit requests with 403 Forbidden. These can help alot, may break some plugins. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ ///.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\=?(http|ftp|ssl|https):/.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\?.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(asp|ini|dll).*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(htpasswd|htaccess|aahtpasswd).*\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>Stop Hotlinking</h3>
<p>Denies any request for static files (images, css, etc) if referrer is not local site or empty. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{HTTP_REFERER} !^http://www.askapache.com.*$ [NC]
RewriteRule \.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$ - [F,NS,L]</pre>

<h3>Safe Request Methods</h3>
<p>Denies any request not using <a href="http://www.askapache.com/online-tools/request-method-scanner/">GET,PROPFIND,POST,OPTIONS,PUT,HEAD</a>[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST|PROPFIND|OPTIONS|PUT)$ [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>Forbid Proxies</h3>
<p>Denies any POST Request using a Proxy Server. Can still access site, but not comment.  See <a href="http://perishablepress.com/press/2008/04/20/how-to-block-proxy-servers-via-htaccess/">Perishable Press</a> [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:VIA}%{HTTP:FORWARDED}%{HTTP:USERAGENT_VIA}%{HTTP:X_FORWARDED_FOR}%{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}%{HTTP:HTTP_PC_REMOTE_ADDR}%{HTTP:HTTP_CLIENT_IP} !^$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>Real wp-comments-post.php</h3>
<p>Denies any POST attempt made to a non-existing wp-comments-post.php[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*/wp-comments-post\.php.*\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>HTTP PROTOCOL</h3>
<p>Denies any badly formed HTTP PROTOCOL in the request, 0.9, 1.0, and 1.1 only[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ .+\ HTTP/(0\.9|1\.0|1\.1) [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>SPECIFY CHARACTERS</h3>
<p>Denies any request for a url containing characters other than "a-zA-Z0-9.+/-?=&amp;"  - REALLY helps but may break your site depending on your links. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&amp;]+\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>BAD Content Length</h3>
<p>Denies any POST request that doesnt have a Content-Length Header[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:Content-Length} ^$
RewriteCond %{REQUEST_URI} !^/(wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>BAD Content Type</h3>
<p>Denies any POST request with a content type other than application/x-www-form-urlencoded|multipart/form-data[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:Content-Type} !^(application/x-www-form-urlencoded|multipart/form-data.*(boundary.*)?)$ [NC]
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>Missing HTTP_HOST</h3>
<p>Denies requests that dont contain a HTTP HOST Header.[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{HTTP_HOST} ^$
RewriteRule .* - [F,NS,L]</pre>

<h3>Bogus Graphics Exploit</h3>
<p>Denies obvious exploit using bogus graphics[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{HTTP:Content-Disposition} \.php [NC]
RewriteCond %{HTTP:Content-Type} image/.+ [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>No UserAgent, Not POST</h3>
<p>Denies POST requests by blank user-agents.  May prevent a small number of visitors from POSTING. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>No Referer, No Comment</h3>
<p>Denies any comment attempt with a blank HTTP_REFERER field, highly indicative of spam.  May prevent some visitors from POSTING. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*/wp-comments-post\.php.*\ HTTP/ [NC]
RewriteCond %{HTTP_REFERER} ^-?$
RewriteRule .* - [F,NS,L]</pre>

<h3>Trackback Spam</h3>
<p>Denies obvious trackback spam.  See Holy Shmoly! [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP_USER_AGENT} ^.*(opera|mozilla|firefox|msie|safari).*$ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.+/trackback/?\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]</pre>

<h3>Map all URIs except those corresponding to existing files to a handler</h3>
<pre>RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule . /script.php</pre>

<h3>Map any request to a handler</h3>
<p>In the case where all URIs should be sent to the same place (including potentially requests for static content) the method to use depends on the type of the handler. For php scripts, use:
For other handlers such as php scripts, use:</p>
<pre>RewriteEngine On
RewriteCond %{REQUEST_URI} !=/script.php
RewriteRule .* /script.php</pre>

<h3>And for CGI scripts:</h3>
<pre>ScriptAliasMatch .* /var/www/script.cgi</pre>

<h3>Map URIs corresponding to existing files to a handler instead</h3>
<pre>RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteCond %{REQUEST_URI} !=/script.php
RewriteRule .* /script.php</pre>
<p>If the existing files you wish to have handled by your script have a common set of file extensions distinct from that of the hander, you can bypass mod_rewrite and use instead mod_actions. Let's say you want all .html and .tpl files to be dealt with by your script:</p>
<pre>Action foo-action /script.php
AddHandler foo-action html tpl</pre>

<h3>Deny access if var=val contains the string foo.</h3>
<pre>RewriteCond %{QUERY_STRING} foo
RewriteRule ^/url - [F]</pre>

<h3>Removing the Query String</h3>
<pre>RewriteRule ^/url /url?</pre>

<h3>Adding to the Query String</h3>
<p>Keep the existing query string using the Query String Append flag, but add var=val to the end.</p>
<pre>RewriteRule ^/url /url?var=val [QSA]</pre>

<h3>Rewriting For Certain Query Strings</h3>
<p>Rewrite URLs like http://askapache.com/url1?var=val to http://askapache.com/url2?var=val but don't rewrite if val isn't present.</p>
<pre>RewriteCond %{QUERY_STRING} val
RewriteRule ^/url1 /url2</pre>

<h3>Modifying the Query String</h3>
<p>Change any single instance of val in the query string to other_val when accessing /path. Note that %1 and %2 are back-references to the matched part of the regular expression in the previous RewriteCond.</p>
<pre>RewriteCond %{QUERY_STRING} ^(.*)val(.*)$
RewriteRule /path /path?%1other_val%2</pre>
<hr class="C" />






<h2>Best .htaccess Articles</h2>

<h3><a title="Apache HTTP Web Server htaccess tips and tricks" rel="chapter" href="http://www.askapache.com/htaccess/htaccess-for-webmasters.html">.htaccess for Webmasters</a></h3><ul><li><a title="htaccess trick to run requests through a cgi script" href="/htaccess/htaccess-for-webmasters.html#process-file-through-cgi">Process certain requests for files using a cgi script</a></li><li><a title="htaccess security for apache hacking" href="/htaccess/htaccess-for-webmasters.html#process-request-methods-with-script">Process Requests with certain Request Methods</a></li><li><a title="Apache ForceType Directive in htaccess process file" href="/htaccess/htaccess-for-webmasters.html#force-filetype-with-forcetype">Make any file be a certain filetype</a></li><li><a title="Using the IfModule Directive in Apache htaccess files." href="/htaccess/htaccess-for-webmasters.html#ifmodule-in-apache">Use IfModule directive for robust code</a></li></ul>

<h3><a title="mod_rewrite RewriteRule, RewriteCond help" rel="chapter" href="http://www.askapache.com/htaccess/modrewrite-tips-tricks.html">Mod_Rewrite URL Rewriting</a></h3><p><a class="hs hs13" href="/htaccess/crazy-advanced-mod_rewrite-tutorial.html#decoded"></a>Undocumented techniques and methods will allow you to utilize mod_rewrite at an  "expert level" by showing you how to <a href="/htaccess/crazy-advanced-mod_rewrite-tutorial.html#decoded">unlock its secrets</a>.</p><ul><li><a title="Search query string at QUERY_STRING" href="/htaccess/modrewrite-tips-tricks.html#check-for-key-in-query-string">Check for a key in QUERY_STRING</a></li><li><a title="Deny access using htaccess during certain time" href="/htaccess/modrewrite-tips-tricks.html#time-based-access">Block access to files during certain hours of the day</a></li><li><a title="Change underscores to hyphens for SEO URL" href="/htaccess/modrewrite-tips-tricks.html#convert-underscore-hyphen">Rewrite underscores to hyphens for SEO URL</a></li><li><a title="Rewriting WordPress RSS feeds to Feedburner in SEO friendly method" href="/htaccess/modrewrite-tips-tricks.html#redirect-wordpress-feed">Redirecting WordPress Feeds to Feedburner</a></li></ul>

<h3><a title="301 Redirects" rel="chapter" href="http://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html">301 Redirects without mod_rewrite</a></h3><ul><li><a title="301 Redirect single file" href="/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-301-redirect-single-file">Redirect single url</a></li><li><a title="301 Redirect new domain" href="/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-301-redirect-new-domain">Redirect to new Domain</a></li></ul>

<h3><a href="/htaccess/php-cgi-redirect_status.html">Secure PHP with .htaccess</a></h3>
<p><a class="IFL" title="Locking down your php.ini and php cgi with .htaccess" href="/htaccess/php-cgi-redirect_status.html"><img src="http://uploads.askapache.com/2008/01/jail-bars-1.png" alt="Locking down your php.ini and php cgi with .htaccess" title="Locking down your php.ini and php cgi with .htaccess" /></a>If you have a php.cgi or php.ini file in your /cgi-bin/ directory or other pub directory, try requesting them from your web browser.  If your php.ini shows up or worse you are able to execute your php cgi, you'll need to secure it ASAP.  This shows several ways to secure these files, and other interpreters like perl, fastCGI, bash, csh, etc.<br class="C" /></p>

<h3><a href="/htaccess/htaccess-fresh.html">.htaccess Cookie Manipulation</a></h3><p><a class="IFL" title="Cookie Manipulation in .htaccess with RewriteRule" href="/htaccess/htaccess-fresh.html"><img src="http://uploads.askapache.com/2007/10/cookies.png" alt="Cookie Manipulation in .htaccess with RewriteRule" title="Cookie Manipulation in .htaccess with RewriteRule" /></a><strong>Fresh <a href="/htaccess/htaccess.html">.htaccess</a> code</strong> for you!  Check out the Cookie Manipulation and environment variable usage with mod_rewrite!  I also included a couple Mod_Security .htaccess examples. <strong>Enjoy!</strong><br class="C" /></p><ul><li><a href="/htaccess/htaccess-fresh.html#modrewrite1">Mod_Rewrite .htaccess Examples</a></li><li><a href="/htaccess/htaccess-fresh.html#modrewrite2">Cookie Manipulation and Tests with mod_rewrite</a></li><li><a href="/htaccess/htaccess-fresh.html#modrewrite3">Setting Environment Variables</a></li><li><a href="/htaccess/htaccess-fresh.html#modrewrite4">Using the Environment Variable</a></li><li><a href="/htaccess/htaccess-fresh.html#modrewrite5">Mod_Security .htaccess Examples</a></li></ul>

<h3><a title="htaccess Caching" rel="chapter" href="http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html">.htaccess Caching</a></h3><ul><li><a href="/htaccess/speed-up-sites-with-htaccess-caching.html">Speed Up Sites with htaccess Caching</a></li><li><a title="htaccess time cheatsheet" href="/htaccess/speed-up-your-site-with-caching-and-cache-control.html#htaccess-time-cheatsheet">htaccess time cheat sheet</a></li></ul>

<h3><a title="401, 403 htpasswd authentication" rel="chapter" href="http://www.askapache.com/htaccess/apache-authentication-in-htaccess.html">Password Protection and Authentication</a></h3><ul><li><a title="Requiring a password for single file" href="/htaccess/apache-authentication-in-htaccess.html#require-password-for-single-file">Require password for single file</a></li><li><a title="A comprehensive default Apache .htaccess example file" href="/htaccess/apache-authentication-in-htaccess.html#skeleton-htaccess">Example .htaccess file for password protection</a></li></ul>

<h3><a title="Creating and using HTTP Headers with htaccess" rel="chapter" href="http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html">Control HTTP Headers</a></h3><ul><li><a title="Prevent Browsers and Proxies from caching" href="/htaccess/using-http-headers-with-htaccess.html#prevent-caching-with-htaccess">Prevent Caching 100%</a></li><li><a title="Remove Internet Explorer imagetoolbar" href="/htaccess/using-http-headers-with-htaccess.html#remove-ie-imagetoolbar">Remove IE imagetoolbar without meta tag</a></li><li><a title="How To use Apache to send P3P Privacy Header for website" href="/htaccess/using-http-headers-with-htaccess.html#privacy-p3p-header-in-apache">Add Privacy (P3P) Header to your site</a></li><li><a title="Language header, Charset header without meta" href="/htaccess/using-http-headers-with-htaccess.html#language-and-content-header-in-htaccess">Add language and charset headers without meta tags</a></li></ul>

<h3><a href="/htaccess/blocking-bad-bots-and-scrapers-with-htaccess.html">Blocking Spam and bad Bots</a></h3><p><a class="IFR" href="/htaccess/blocking-bad-bots-and-scrapers-with-htaccess.html"><img title="Block Bad Robot" src="http://uploads.askapache.com/2008/04/bad_robot1.png" alt="Block Bad Robot" height="100" /></a>Want to block a bad robot or web scraper using .htaccess files?  Here are 2 methods that illustrate blocking 436 various user-agents.  You can block them using either SetEnvIf methods, or by using Rewrite Blocks.<br class="C" /></p>

<h3><a title="php htaccess tips, htaccess php tricks" rel="chapter" href="http://www.askapache.com/htaccess/php-htaccess-tips-and-tricks.html">PHP htaccess tips</a></h3><p>By using some cool .htaccess tricks we can control PHP to be run as a cgi or a module.  If php is run as a cgi then we need to compile it ourselves or use .htaccess to force php to use a local php.ini file.  If it is running as a module then we can use various directives supplied by that modules in .htaccess</p><ul><li><a title=".htaccess for php as cgi" href="/htaccess/php-htaccess-tips-and-tricks.html#php-run-as-cgi">When php run as CGI</a></li><li><a title="custom php.ini with Apache htaccess using PHPRC" href="/htaccess/php-htaccess-tips-and-tricks.html#htaccess-php-ini">Use a custom php.ini with mod_php or php as a cgi</a></li><li><a title="htaccess tips for mod_php php running as Apache module" href="/htaccess/php-htaccess-tips-and-tricks.html#sub-mod_php">When php run as Apache Module (mod_php)</a></li><li><a title="Apache FastCGI wrapper for php cgi" href="/htaccess/php-htaccess-tips-and-tricks.html#php-and-fastcgi-in-htaccess">When cgi php is run with wrapper (FastCGI)</a></li></ul>

<h3><a href="/htaccess/http-https-rewriterule-redirect.html">HTTP to HTTPS Redirects with mod_rewrite</a></h3><p><a href="/htaccess/http-https-rewriterule-redirect.html"><img class="IFL" src="http://uploads.askapache.com/2007/11/security.png" alt="HTTP to HTTPS Redirects with mod_rewrite" title="HTTP to HTTPS Redirects with mod rewrite" /></a>This is freaking sweet if you use SSL I promise you!  Basically instead of having to check for HTTPS using a <code>RewriteCond %{HTTPS} =on</code> for every redirect that can be either HTTP or HTTPS, I set an environment variable once with the value "http" or "https" if HTTP or HTTPS is being used for that request, and use that env variable in the RewriteRule.<br class="C" /></p>

<h3><a title="Apache SSL examples" rel="chapter" href="http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html">SSL in .htaccess</a></h3><ul><li><a title="Redirecting non-SSL to SSL in Apache" href="/htaccess/ssl-example-usage-in-htaccess.html#redirect-http-to-https">Redirect non-https requests to https server</a></li><li><a title="redirect HTTP to HTTPS without mod_ssl!" href="/htaccess/ssl-example-usage-in-htaccess.html#rewrite-http-to-https-no-mod_ssl">Rewrite non-https to HTTPS without mod_ssl!</a></li><li><a title="Redirect HTTP to HTTPS by port" href="/htaccess/ssl-example-usage-in-htaccess.html#redirect-port-80-to-https">Redirect everything served on port 80 to HTTPS URI</a></li></ul>

<h3><a title="Conditionally setting variables in Apache .htaccess" rel="chapter" href="http://www.askapache.com/htaccess/setenvif.html">SetEnvIf and SetEnvIfNoCase in .htaccess</a></h3><ul><li><a title="Unique mod_setenvif Variables" href="/htaccess/setenvif.html#setenvif-variables">Unique mod_setenvif Variables</a></li><li><a title="Populates HTTP_MY_ Variables with mod_setenvif variable values" href="/htaccess/setenvif.html#http-headers">Populates HTTP_MY_ Variables with mod_setenvif variable values</a></li><li><a title="Allows only if HOST Header is present in request" href="/htaccess/setenvif.html#allow-host">Allows only if HOST Header is present in request</a></li><li><a title="Add values from HTTP Headers" href="/htaccess/setenvif.html#header-copy">Add values from HTTP Headers</a></li></ul>

<h3><a title="htaccess security and hacking" rel="chapter" href="http://www.askapache.com/htaccess/security-with-htaccess.html">Site Security with .htaccess</a></h3>
<p>chmod .htpasswd files 640, chmod .htaccess 644, php files 600, and chmod files that you really dont want people to see as 400. (NEVER chmod 777, try 766)</p>
<ul><li><a title="CHMOD .htaccess, chmod .htpasswd, chmodding files" href="/htaccess/security-with-htaccess.html#chmod-htaccess-info">CHMOD your files</a></li><li><a title="Deny access for htaccess/htpasswd file" href="/htaccess/security-with-htaccess.html#deny-htaccess-htpasswd-access">Prevent access to .htaccess and .htpasswd files</a></li><li><a title="Show source code in browser, prevent executing file" href="/htaccess/security-with-htaccess.html#show-source-code">Show Source Code instead of executing</a></li><li><a title="Remove execution privileges" href="/htaccess/security-with-htaccess.html#securing-directories-with-htaccess">Securing directories: Remove ability to execute scripts</a></li><li><a title="ErrorDocument usage in htaccess files" href="/htaccess/security-with-htaccess.html#errordocument-usage-in-htaccess">.htaccess ErrorDocuments</a></li></ul>





<h3>Merging Notes</h3>
<p>The order of merging is:</p>
<ol>
<li><code>&lt;Directory&gt;</code> (except regular expressions) and .htaccess done simultaneously (with .htaccess, if allowed, overriding <code>&lt;Directory&gt;</code>)</li>
<li><code>&lt;DirectoryMatch&gt;</code> (and <code>&lt;Directory ~&gt;</code>)</li>
<li><code>&lt;Files&gt;</code> and <code>&lt;FilesMatch&gt;</code> done simultaneously</li>
<li><code>&lt;Location&gt;</code> and <code>&lt;LocationMatch&gt;</code> done simultaneously</li>
</ol>



<h2>My Favorite .htaccess Links</h2>
<p class="anote">These are just some of my favorite .htaccess resources.  I'm really into doing your own hacking to get knowledge and these links are all great resources in that respect.  I'm really interested in new or unusual htaccess solutions or htaccess hacks using .htaccess files, so let me know if you find one.</p>
<p><strong>NCSA HTTPd Tutorials</strong><br /></p>
<p><strong>Robert Hansen</strong><br />Here's a great <a href="http://www.securityfocus.com/infocus/1368">Hardening HTAccess part 1</a>, <a href="http://www.securityfocus.com/infocus/1369">part 2</a>, <a href="http://www.securityfocus.com/infocus/1370">part 3</a> article that goes into detail about some of the rarer security applications for .htaccess files.</p>
<p><strong>SAMAXES</strong><br />Some very detailed and helpful .htaccess articles, such as the <a href="http://www.samaxes.com/2008/04/20/htaccess-gzip-and-cache-your-site-for-faster-loading-and-bandwidth-saving/">".htaccess - gzip and cache your site for faster loading and bandwidth saving."</a></p>
<p><strong>PerishablePress</strong><br /><a href="http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/">Stupid .htaccess tricks</a> is probably the <strong>best explanation online</strong> for many of the best .htaccess solutions, including many from this page. Unlike me they are fantastic writers, even for technical stuff they are very readable, so its a good blog to kick back on and read.  They also have a <a title="Eight Ways to Blacklist with Apache's mod_rewrite" href="http://perishablepress.com/press/2009/02/03/eight-ways-to-blacklist-with-apaches-mod_rewrite/">fantastic article</a> detailing how to block/deny specific requests using mod_rewrite.</p>
<p><strong>BlogSecurity</strong><br />Mostly a site for... blog security (which is really any web-app security) this blog has a few really impressive articles full of solid information for Hardening WordPress with .htaccess among more advanced topics that can be challenging but effective.  This is a good site to subscribe to their feed, they publish plugin exploits and wordpress core vulnerabilities quite a bit.</p>
<p><strong>Check-These</strong><br />Oldschool security/unix dude with some incredibly detailed mod_rewrite tutorials, helped me the most when I first got into this, and a great guy too. See: <a href="http://check-these.info/mod_rewrite-basic.html">Basic Mod_Rewrite Guide</a>, and <a href="http://check-these.info/RewriteRule.html">Advanced Mod_Rewrite Tutorial</a></p>
<p><strong>Reaper-X</strong><br />Alot of .htaccess tutorials and code.  See: <a href="http://www.reaper-x.com/2007/09/01/hardening-wordpress-with-mod-rewrite-and-htaccess/">Hardening WordPress with Mod Rewrite and htaccess</a></p>
<p><strong>jdMorgan</strong><br /><a href="http://www.webmasterworld.com/profilev4.cgi?action=view&amp;member=jdMorgan">jdMorgan</a> is the Moderator of the <a href="http://www.webmasterworld.com/apache/">Apache Forum</a> at WebmasterWorld, a great place for answers.  In my experience he can answer any tough question pertaining to advanced .htaccess usage, haven't seen him stumped yet.</p>
<p><strong>The W3C</strong><br /><a href="http://www.w3.org/International/questions/qa-htaccess-charset">Setting Charset in .htaccess</a> is very informative.<br /></p>
<p><strong>Holy Shmoly!</strong><br />A great blogger with analysis of attacks and spam.  See: More ways to stop spammers and unwanted traffic.</p>
<p><strong>Apache Week</strong><br />A partnership with Red Hat back in the 90's that produced some <a href="http://www.apacheweek.com/features/userauth">excellent documentation</a>.</p>
<p><strong>Corz</strong><br />Here's a resource that I consider to have some of the most creative and ingenious ideas for .htaccess files, although the author is somewhat of a character ;) Its a trip trying to navigate around the site, a fun trip. Its like nothing I've ever seen. There are only a few articles on the site, but the htaccess articles are very original and well-worth a look. See: <a rel="nofollow" href="http://corz.org/serv/tricks/htaccess.php">htaccess tricks and tips</a>.</p>
<hr class="C" />







<h2>Htaccess Directives</h2>
<p class="anote">This is an AskApache.com exclusive <em>you won't find this anywhere else</em>.</p>
<p>Directory, DirectoryMatch, Files, FilesMatch, IfDefine, IfVersion, IfModule, Limit, LimitExcept, Location, LocationMatch, Proxy, ProxyMatch, VirtualHost, AcceptMutex, AcceptPathInfo, AccessFileName, Action, AddCharset, AddDefaultCharset, AddDescription, AddEncoding, AddHandler, AddInputFilter, AddLanguage, AddOutputFilter, AddOutputFilterByType, AddType, Alias, AliasMatch, AllowCONNECT, AllowOverride, Anonymous, Anonymous_Authoritative, Anonymous_LogEmail, Anonymous_MustGiveEmail, Anonymous_NoUserId, Anonymous_VerifyEmail, AuthAuthoritative, AuthDBMAuthoritative, AuthDBMGroupFile, AuthDBMType, AuthDBMUserFile, AuthDigestAlgorithm, AuthDigestDomain, AuthDigestFile, AuthDigestGroupFile, AuthDigestNcCheck, AuthDigestNonceFormat, AuthDigestNonceLifetime, AuthDigestQop, AuthDigestShmemSize, AuthGroupFile, AuthName, AuthType, AuthUserFile, BS2000Account, BrowserMatch, BrowserMatchNoCase, CacheNegotiatedDocs, CharsetDefault, CharsetOptions, CharsetSourceEnc, CheckSpelling, ContentDigest, CookieDomain, CookieExpires, CookieName, CookieStyle, CookieTracking, CoreDumpDirectory, DAV, DAVDepthInfinity, DAVMinTimeout, DefaultIcon, DefaultLanguage, DefaultType, DocumentRoot, ErrorDocument, ErrorLog, ExtFilterDefine, ExtFilterOptions, FancyIndexing, FileETag, ForceLanguagePriority, ForceType, GprofDir, Header, HeaderName, HostnameLookups, IdentityCheck, ImapBase, ImapDefault, ImapMenu, Include, IndexIgnore, LanguagePriority, LimitRequestBody, LimitRequestFields, LimitRequestFieldsize, LimitRequestLine, LimitXMLRequestBody, LockFile, LogLevel, MaxRequestsPerChild, MultiviewsMatch, NameVirtualHost, NoProxy, Options, PassEnv, PidFile, Port, ProxyBlock, ProxyDomain, ProxyErrorOverride, ProxyIOBufferSize, ProxyMaxForwards, ProxyPass, ProxyPassReverse, ProxyPreserveHost, ProxyReceiveBufferSize, ProxyRemote, ProxyRemoteMatch, ProxyRequests, ProxyTimeout, ProxyVia, RLimitCPU, RLimitMEM, RLimitNPROC, ReadmeName, Redirect, RedirectMatch, RedirectPermanent, RedirectTemp, RemoveCharset, RemoveEncoding, RemoveHandler, RemoveInputFilter, RemoveLanguage, RemoveOutputFilter, RemoveType, RequestHeader, Require, RewriteCond, RewriteRule, SSIEndTag, SSIErrorMsg, SSIStartTag, SSITimeFormat, SSIUndefinedEcho, Satisfy, ScoreBoardFile, Script, ScriptAlias, ScriptAliasMatch, ScriptInterpreterSource, ServerAdmin, ServerAlias, ServerName, ServerPath, ServerRoot, ServerSignature, ServerTokens, SetEnv, SetEnvIf, SetEnvIfNoCase, SetHandler, SetInputFilter, SetOutputFilter, Timeout, TypesConfig, UnsetEnv, UseCanonicalName, XBitHack, allow, deny, order, CGIMapExtension, EnableMMAP, ISAPIAppendLogToErrors, ISAPIAppendLogToQuery, ISAPICacheFile, ISAPIFakeAsync, ISAPILogNotSupported, ISAPIReadAheadBuffer, SSLLog, SSLLogLevel, MaxMemFree, ModMimeUsePathInfo, EnableSendfile, ProxyBadHeader, AllowEncodedSlashes, LimitInternalRecursion, EnableExceptionHook, TraceEnable, ProxyFtpDirCharset, AuthBasicAuthoritative, AuthBasicProvider, AuthDefaultAuthoritative, AuthDigestProvider, AuthLDAPAuthzEnabled, AuthLDAPBindDN, AuthLDAPBindPassword, AuthLDAPCharsetConfig, AuthLDAPCompareDNOnServer, AuthLDAPDereferenceAliases, AuthLDAPGroupAttribute, AuthLDAPGroupAttributeIsDN, AuthLDAPRemoteUserIsDN, AuthLDAPURL, AuthzDBMAuthoritative, AuthzDBMType, AuthzDefaultAuthoritative, AuthzGroupFileAuthoritative, AuthzLDAPAuthoritative, AuthzOwnerAuthoritative, AuthzUserAuthoritative, BalancerMember, DAVGenericLockDB, FilterChain, FilterDeclare, FilterProtocol, FilterProvider, FilterTrace, IdentityCheckTimeout, IndexStyleSheet, ProxyPassReverseCookieDomain, ProxyPassReverseCookiePath, ProxySet, ProxyStatus, ThreadStackSize, AcceptFilter, Protocol, AuthDBDUserPWQuery, AuthDBDUserRealmQuery, UseCanonicalPhysicalPort, CheckCaseOnly, AuthLDAPRemoteUserAttribute, ProxyPassMatch, SSIAccessEnable, Substitute, ProxyPassInterpolateEnv</p>
<hr class="C" />







<h2>Htaccess Modules</h2>
<p>Here are most of the modules that come with Apache.  Each one can have new commands that can be used in .htaccess file scopes.</p>
<p><a href="/servers/mod_actions.c.html">mod_actions</a>, <a href="/servers/mod_alias.c.html">mod_alias</a>, <a href="/servers/mod_asis.c.html">mod_asis</a>, <a href="/servers/mod_auth_basic.c.html">mod_auth_basic</a>, <a href="/servers/mod_auth_digest.c.html">mod_auth_digest</a>, <a href="/servers/mod_authn_anon.c.html">mod_authn_anon</a>, <a href="/servers/mod_authn_dbd.c.html">mod_authn_dbd</a>, <a href="/servers/mod_authn_dbm.c.html">mod_authn_dbm</a>, <a href="/servers/mod_authn_default.c.html">mod_authn_default</a>, <a href="/servers/mod_authn_file.c.html">mod_authn_file</a>, <a href="/servers/mod_authz_dbm.c.html">mod_authz_dbm</a>, <a href="/servers/mod_authz_default.c.html">mod_authz_default</a>, <a href="/servers/mod_authz_groupfile.c.html">mod_authz_groupfile</a>, <a href="/servers/mod_authz_host.c.html">mod_authz_host</a>, <a href="/servers/mod_authz_owner.c.html">mod_authz_owner</a>, <a href="/servers/mod_authz_user.c.html">mod_authz_user</a>, <a href="/servers/mod_autoindex.c.html">mod_autoindex</a>, <a href="/servers/mod_cache.c.html">mod_cache</a>, <a href="/servers/mod_cern_meta.c.html">mod_cern_meta</a>, <a href="/servers/mod_cgi.c.html">mod_cgi</a>, <a href="/servers/mod_dav.c.html">mod_dav</a>, <a href="/servers/mod_dav_fs.c.html">mod_dav_fs</a>, <a href="/servers/mod_dbd.c.html">mod_dbd</a>, <a href="/servers/mod_deflate.c.html">mod_deflate</a>, <a href="/servers/mod_dir.c.html">mod_dir</a>, <a href="/servers/mod_disk_cache.c.html">mod_disk_cache</a>, <a href="/servers/mod_dumpio.c.html">mod_dumpio</a>, <a href="/servers/mod_env.c.html">mod_env</a>, <a href="/servers/mod_expires.c.html">mod_expires</a>, <a href="/servers/mod_ext_filter.c.html">mod_ext_filter</a>, <a href="/servers/mod_file_cache.c.html">mod_file_cache</a>, <a href="/servers/mod_filter.c.html">mod_filter</a>, <a href="/servers/mod_headers.c.html">mod_headers</a>, <a href="/servers/mod_ident.c.html">mod_ident</a>, <a href="/servers/mod_imagemap.c.html">mod_imagemap</a>, <a href="/servers/mod_include.c.html">mod_include</a>, <a href="/servers/mod_info.c.html">mod_info</a>, <a href="/servers/mod_log_config.c.html">mod_log_config</a>, <a href="/servers/mod_log_forensic.c.html">mod_log_forensic</a>, <a href="/servers/mod_logio.c.html">mod_logio</a>, <a href="/servers/mod_mem_cache.c.html">mod_mem_cache</a>, <a href="/servers/mod_mime.c.html">mod_mime</a>, <a href="/servers/mod_mime_magic.c.html">mod_mime_magic</a>, <a href="/servers/mod_negotiation.c.html">mod_negotiation</a>, <a href="/servers/mod_proxy.c.html">mod_proxy</a>, <a href="/servers/mod_proxy_ajp.c.html">mod_proxy_ajp</a>, <a href="/servers/mod_proxy_balancer.c.html">mod_proxy_balancer</a>, <a href="/servers/mod_proxy_connect.c.html">mod_proxy_connect</a>, <a href="/servers/mod_proxy_ftp.c.html">mod_proxy_ftp</a>, <a href="/servers/mod_proxy_http.c.html">mod_proxy_http</a>, <a href="/servers/mod_rewrite.c.html">mod_rewrite</a>, <a href="/servers/mod_setenvif.c.html">mod_setenvif</a>, <a href="/servers/mod_speling.c.html">mod_speling</a>, <a href="/servers/mod_ssl.c.html">mod_ssl</a>, <a href="/servers/mod_status.c.html">mod_status</a>, <a href="/servers/mod_substitute.c.html">mod_substitute</a>, <a href="/servers/mod_unique_id.c.html">mod_unique_id</a>, <a href="/servers/mod_userdir.c.html">mod_userdir</a>, <a href="/servers/mod_usertrack.c.html">mod_usertrack</a>, <a href="/servers/mod_version.c.html">mod_version</a>, <a href="/servers/mod_vhost_alias.c.html">mod_vhost_alias</a></p>
<hr class="C" />





<h2>Htaccess Software</h2>
<p>Apache HTTP Server comes with the following <a href="http://httpd.apache.org/docs/trunk/programs/">programs</a>.</p>
<dl><dt><code>httpd</code></dt><dd>Apache hypertext transfer protocol server</dd><dt><code>apachectl</code></dt><dd>Apache HTTP server control interface</dd><dt><code>ab</code></dt><dd>Apache HTTP server benchmarking tool</dd><dt><code>apxs</code></dt><dd>APache eXtenSion tool</dd><dt><code>dbmmanage</code></dt><dd>Create and update user authentication files in DBM format for basic authentication</dd><dt><code>fcgistarter</code></dt><dd>Start a FastCGI program</dd><dt><code>htcacheclean</code></dt><dd>Clean up the disk cache</dd><dt><code>htdigest</code></dt><dd>Create and update user authentication files for digest authentication</dd><dt><code>htdbm</code></dt><dd>Manipulate DBM password databases.</dd><dt><code>htpasswd</code></dt><dd>Create and update user authentication files for basic authentication</dd><dt><code>httxt2dbm</code></dt><dd>Create dbm files for use with RewriteMap</dd><dt><code>logresolve</code></dt><dd>Resolve hostnames for IP-addresses in Apache logfiles</dd><dt>log_server_status</dt><dd>Periodically log the server's status</dd><dt><code>rotatelogs</code></dt><dd>Rotate Apache logs without having to kill the server</dd><dt>split-logfile</dt><dd>Split a multi-vhost logfile into per-host logfiles</dd><dt><code>suexec</code></dt><dd>Switch User For Exec</dd></dl>




















<h2>Technical Look at .htaccess</h2>
<p><a href="http://httpd.apache.org/docs/1.3/misc/API.html">Source: Apache API notes</a></p>
<h3>Per-directory configuration structures</h3>
<p>Let's look out how all of this plays out in mod_mime.c, which defines the file typing handler which emulates the NCSA server's behavior of determining file types from suffixes. What we'll be looking at, here, is the code which implements the AddType and AddEncoding commands. These commands can appear in .htaccess files, so they must be handled in the module's private per-directory data, which in fact, consists of two separate tables for MIME types and encoding information, and is declared as follows:</p>

<pre>table *forced_types;      /* Additional AddTyped stuff */
table *encoding_types;    /* Added with AddEncoding... */
mime_dir_config;</pre>

<p>When the server is reading a configuration file, or &lt;Directory&gt; section, which includes one of the MIME module's commands, it needs to create a mime_dir_config structure, so those commands have something to act on. It does this by invoking the function it finds in the module's `create per-dir config slot', with two arguments: the name of the directory to which this configuration information applies (or NULL for srm.conf), and a pointer to a resource pool in which the allocation should happen.</p>

<p>(If we are reading a .htaccess file, that resource pool is the per-request resource pool for the request; otherwise it is a resource pool which is used for configuration data, and cleared on restarts. Either way, it is important for the structure being created to vanish when the pool is cleared, by registering a cleanup on the pool if necessary).</p>

<p>For the MIME module, the per-dir config creation function just ap_pallocs the structure above, and a creates a couple of tables to fill it. That looks like this:</p>

<pre>void *create_mime_dir_config (pool *p, char *dummy)
mime_dir_config *new = (mime_dir_config *) ap_palloc (p, sizeof(mime_dir_config));
&nbsp;
new-&gt;forced_types = ap_make_table (p, 4);
new-&gt;encoding_types = ap_make_table (p, 4);</pre>


<p>Now, suppose we've just read in a .htaccess file. We already have the per-directory configuration structure for the next directory up in the hierarchy. If the .htaccess file we just read in didn't have any AddType or AddEncoding commands, its per-directory config structure for the MIME module is still valid, and we can just use it. Otherwise, we need to merge the two structures somehow.</p>

<p>To do that, the server invokes the module's per-directory config merge function, if one is present. That function takes three arguments: the two structures being merged, and a resource pool in which to allocate the result. For the MIME module, all that needs to be done is overlay the tables from the new per-directory config structure with those from the parent:</p>

<pre>void *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv)
mime_dir_config *parent_dir = (mime_dir_config *)parent_dirv;
mime_dir_config *subdir = (mime_dir_config *)subdirv;
mime_dir_config *new =  (mime_dir_config *)ap_palloc (p, sizeof(mime_dir_config));
new-&gt;forced_types = ap_overlay_tables (p, subdir-&gt;forced_types, parent_dir-&gt;forced_types);
new-&gt;encoding_types = ap_overlay_tables (p, subdir-&gt;encoding_types, parent_dir-&gt;encoding_types);</pre>


<p>As a note --- if there is no per-directory merge function present, the server will just use the subdirectory's configuration info, and ignore the parent's. For some modules, that works just fine (e.g., for the includes module, whose per-directory configuration information consists solely of the state of the XBITHACK), and for those modules, you can just not declare one, and leave the corresponding structure slot in the module itself NULL.</p>

<h3>Command handling</h3>
<p>Now that we have these structures, we need to be able to figure out how to fill them. That involves processing the actual AddType and AddEncoding commands. To find commands, the server looks in the module's command table. That table contains information on how many arguments the commands take, and in what formats, where it is permitted, and so forth. That information is sufficient to allow the server to invoke most command-handling functions with pre-parsed arguments. Without further ado, let's look at the AddType command handler, which looks like this (the AddEncoding command looks basically the same, and won't be shown here):</p>
<pre>char *add_type(cmd_parms *cmd, mime_dir_config *m, char *ct, char *ext)
if (*ext == &#039;.&#039;) ++ext;
ap_table_set (m-&gt;forced_types, ext, ct);</pre>


<p>This command handler is unusually simple. As you can see, it takes four arguments, two of which are pre-parsed arguments, the third being the per-directory configuration structure for the module in question, and the fourth being a pointer to a cmd_parms structure. That structure contains a bunch of arguments which are frequently of use to some, but not all, commands, including a resource pool (from which memory can be allocated, and to which cleanups should be tied), and the (virtual) server being configured, from which the module's per-server configuration data can be obtained if required.</p>

<p>Another way in which this particular command handler is unusually simple is that there are no error conditions which it can encounter. If there were, it could return an error message instead of NULL; this causes an error to be printed out on the server's stderr, followed by a quick exit, if it is in the main config files; for a .htaccess file, the syntax error is logged in the server error log (along with an indication of where it came from), and the request is bounced with a server error response (HTTP error status, code 500).</p>

<p>The MIME module's command table has entries for these commands, which look like this:</p>
<pre>command_rec mime_cmds[] =
{ "AddType", add_type, NULL, OR_FILEINFO, TAKE2, "a mime type followed by a file extension" },
{ "AddEncoding", add_encoding, NULL, OR_FILEINFO, TAKE2, "an encoding (e.g., gzip), followed by a file extension" },</pre>

<p>Here's a taste of that famous Apache source code that builds the directives allowed in .htaccess file context, the key that tells whether its enabled in .htaccess context is the DIR_CMD_PERMS and then the OR_FILEINFO, which means a directive is enabled dependent on the AllowOverride directive that is only allowed in the main config.  First Apache 1.3.0, then Apache 2.2.10</p>

<h5>mod_autoindex</h5>
<pre>AddIcon, add_icon, BY_PATH, DIR_CMD_PERMS, an icon URL followed by one or more filenames
AddIconByType, add_icon, BY_TYPE, DIR_CMD_PERMS, an icon URL followed by one or more MIME types
AddIconByEncoding, add_icon, BY_ENCODING, DIR_CMD_PERMS, an icon URL followed by one or more content encodings
AddAlt, add_alt, BY_PATH, DIR_CMD_PERMS, alternate descriptive text followed by one or more filenames
AddAltByType, add_alt, BY_TYPE, DIR_CMD_PERMS, alternate descriptive text followed by one or more MIME types
AddAltByEncoding, add_alt, BY_ENCODING, DIR_CMD_PERMS, alternate descriptive text followed by one or more content encodings
IndexOptions, add_opts, DIR_CMD_PERMS, RAW_ARGS, one or more index options
IndexIgnore, add_ignore, DIR_CMD_PERMS, ITERATE, one or more file extensions
AddDescription, add_desc, BY_PATH, DIR_CMD_PERMS, Descriptive text followed by one or more filenames
HeaderName, add_header, DIR_CMD_PERMS, TAKE1, a filename
ReadmeName, add_readme, DIR_CMD_PERMS, TAKE1, a filename
FancyIndexing, fancy_indexing, DIR_CMD_PERMS, FLAG, Limited to &#039;on&#039; or &#039;off&#039; (superseded by IndexOptions FancyIndexing)
DefaultIcon, ap_set_string_slot, (void *) XtOffsetOf(autoindex_config_rec, default_icon), DIR_CMD_PERMS, TAKE1, an icon URL</pre>

<h5>mod_rewrite</h5>
<pre>// mod_rewrite
RewriteEngine, cmd_rewriteengine, OR_FILEINFO, On or Off to enable or disable (default)
RewriteOptions, cmd_rewriteoptions, OR_FILEINFO, List of option strings to set
RewriteBase, cmd_rewritebase, OR_FILEINFO, the base URL of the per-directory context
RewriteCond, cmd_rewritecond, OR_FILEINFO, an input string and a to be applied regexp-pattern
RewriteRule, cmd_rewriterule, OR_FILEINFO, an URL-applied regexp-pattern and a substitution URL
RewriteMap, cmd_rewritemap, RSRC_CONF, a mapname and a filename
RewriteLock, cmd_rewritelock, RSRC_CONF, the filename of a lockfile used for inter-process synchronization
RewriteLog, cmd_rewritelog, RSRC_CONF, the filename of the rewriting logfile
RewriteLogLevel, cmd_rewriteloglevel, RSRC_CONF, the level of the rewriting logfile verbosity (0=none, 1=std, .., 9=max)
RewriteLog, fake_rewritelog, RSRC_CONF, [DISABLED] the filename of the rewriting logfile
RewriteLogLevel, fake_rewritelog, RSRC_CONF, [DISABLED] the level of the rewriting logfile verbosity</pre>



<p>The entries in these tables are:</p>
<ul>
<li>The name of the command</li>
<li>The function which handles it a (void *) pointer, which is passed in the cmd_parms structure to the command handler --- this is useful in case many similar commands are handled by the same function.</li>
<li>A bit mask indicating where the command may appear. There are mask bits corresponding to each AllowOverride option, and an additional mask bit, RSRC_CONF, indicating that the command may appear in the server's own config files, but not in any .htaccess file.</li>
<li>A flag indicating how many arguments the command handler wants pre-parsed, and how they should be passed in. TAKE2 indicates two pre-parsed arguments. Other options are TAKE1, which indicates one pre-parsed argument, FLAG, which indicates that the argument should be On or Off, and is passed in as a boolean flag, RAW_ARGS, which causes the server to give the command the raw, unparsed arguments (everything but the command name itself). There is also ITERATE, which means that the handler looks the same as TAKE1, but that if multiple arguments are present, it should be called multiple times, and finally ITERATE2, which indicates that the command handler looks like a TAKE2, but if more arguments are present, then it should be called multiple times, holding the first argument constant.</li>
<li>Finally, we have a string which describes the arguments that should be present. If the arguments in the actual config file are not as required, this string will be used to help give a more specific error message. (You can safely leave this NULL).</li>
</ul>



<p>Finally, having set this all up, we have to use it. This is ultimately done in the module's handlers, specifically for its file-typing handler, which looks more or less like this; note that the per-directory configuration structure is extracted from the request_rec's per-directory configuration vector by using the ap_get_module_config function.</p>

<h3>Side notes --- per-server configuration, virtual servers, etc.</h3>
<p>The basic ideas behind per-server module configuration are basically the same as those for per-directory configuration; there is a creation function and a merge function, the latter being invoked where a virtual server has partially overridden the base server configuration, and a combined structure must be computed. (As with per-directory configuration, the default if no merge function is specified, and a module is configured in some virtual server, is that the base configuration is simply ignored).</p>

<p>The only substantial difference is that when a command needs to configure the per-server private module data, it needs to go to the cmd_parms data to get at it. Here's an example, from the alias module, which also indicates how a syntax error can be returned (note that the per-directory configuration argument to the command handler is declared as a dummy, since the module doesn't actually have per-directory config data):</p>


<p><strong>Network Hardware Certification</strong></p>
<p>No doubt Cisco is way ahead then other network hardware and certification providers. Most of fresh IT graduates are going for <a rel="nofollow" href="http://www.certshelp.com/640-802.html">CCNA 640-802 exam</a> in order to start their career in the field of networking. While on the other hand, those who are interested to be hardware technician are attempting <a href="http://www.certshelp.com/sy0-301.html" rel="nofollow">CompTIA sy0-301</a> Exam.</p>


<h3>Litespeed Htaccess support</h3>
<p>Unlike other lightweight web servers, Apache compatible per-directory configuration overridden is fully supported by <a href="http://www.litespeedtech.com/">LiteSpeed Web Server</a>. With .htacess you can change configurations for any directory under document root on-the-fly, which in most cases is a mandatory feature in shared hosting environment.   It is worth noting that <em>enabling .htaccess support in LiteSpeed</em> Web Server will not degrade server's performance, comparing to Apache's 40% drop in performance. </p>



<p><a href="/htaccess/htaccess-rewrite.html">Continue Reading Page 2</a></p><p><a rel="follow" href="http://www.askapache.com/htaccess/htaccess.html"></a> &hellip;<a href="http://www.askapache.com/htaccess/htaccess.html">Htaccess &#8211; The Ultimate Guide</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/htaccess/htaccess.html">Htaccess &#8211; The Ultimate Guide</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/V3MucJTilfg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/htaccess.html/feed/</wfw:commentRss>
		<slash:comments>83</slash:comments>
		<feedburner:origLink>http://www.askapache.com/htaccess/htaccess.html</feedburner:origLink></item>
		<item>
		<title>Htaccess Rewrite for Redirecting Uppercase to Lowercase</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/KzHYJf13omY/rewrite-uppercase-lowercase.html</link>
		<comments>http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html#comments</comments>
		<pubDate>Tue, 30 Apr 2013 13:21:48 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[mod_speling]]></category>
		<category><![CDATA[RewriteCond]]></category>
		<category><![CDATA[RewriteRule]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8870</guid>
		<description><![CDATA[<p><p>Want to redirect all links with any uppercase characters to lowercase using pure mod_rewrite within an .htaccess file?  Sure why not!  OR how to use RewriteMap and mod_speling for those with access to <code>httpd.conf</code></p></p><p>The post <a href="http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html">Htaccess Rewrite for Redirecting Uppercase to Lowercase</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html"></a><a href="http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html"><cite>AskApache.com</cite></a></p><p>Want to redirect all links with any uppercase characters to lowercase using pure mod_rewrite within an .htaccess file?  Sure why not!  OR how to use RewriteMap and mod_speling for those with access to <code>httpd.conf</code></p>


<h2>Htaccess to Redirect Uppercase to Lowercase</h2>
<p>This should go at the very top of your <a href="http://www.askapache.com/htaccess/htaccess.html">.htaccess file</a>.  At least it should go <strong>above ANY other RewriteRules</strong>. That is because this uses a loop, until there are no more uppercase characters to convert, it will keep starting at the first <code>HASCAPS:TRUE</code> RewriteRule.  Oh, and this is actually really quick and isn't gonna slow down anything.</p>
<pre>RewriteEngine On
RewriteBase /
&nbsp;
# If there are caps, set HASCAPS to true and skip next rule
RewriteRule [A-Z] - [E=HASCAPS:TRUE,S=1]
&nbsp;
# Skip this entire section if no uppercase letters in requested URL
RewriteRule ![A-Z] - [S=28]
&nbsp;
# Replace single occurance of CAP with cap, then process next Rule.
RewriteRule ^([^A]*)A(.*)$ $1a$2
RewriteRule ^([^B]*)B(.*)$ $1b$2
RewriteRule ^([^C]*)C(.*)$ $1c$2
RewriteRule ^([^D]*)D(.*)$ $1d$2
RewriteRule ^([^E]*)E(.*)$ $1e$2
RewriteRule ^([^F]*)F(.*)$ $1f$2
RewriteRule ^([^G]*)G(.*)$ $1g$2
RewriteRule ^([^H]*)H(.*)$ $1h$2
RewriteRule ^([^I]*)I(.*)$ $1i$2
RewriteRule ^([^J]*)J(.*)$ $1j$2
RewriteRule ^([^K]*)K(.*)$ $1k$2
RewriteRule ^([^L]*)L(.*)$ $1l$2
RewriteRule ^([^M]*)M(.*)$ $1m$2
RewriteRule ^([^N]*)N(.*)$ $1n$2
RewriteRule ^([^O]*)O(.*)$ $1o$2
RewriteRule ^([^P]*)P(.*)$ $1p$2
RewriteRule ^([^Q]*)Q(.*)$ $1q$2
RewriteRule ^([^R]*)R(.*)$ $1r$2
RewriteRule ^([^S]*)S(.*)$ $1s$2
RewriteRule ^([^T]*)T(.*)$ $1t$2
RewriteRule ^([^U]*)U(.*)$ $1u$2
RewriteRule ^([^V]*)V(.*)$ $1v$2
RewriteRule ^([^W]*)W(.*)$ $1w$2
RewriteRule ^([^X]*)X(.*)$ $1x$2
RewriteRule ^([^Y]*)Y(.*)$ $1y$2
RewriteRule ^([^Z]*)Z(.*)$ $1z$2
&nbsp;
# If there are any uppercase letters, restart at very first RewriteRule in file.
RewriteRule [A-Z] - [N]
&nbsp;
RewriteCond %{ENV:HASCAPS} TRUE
RewriteRule ^/?(.*) /$1 [R=301,L]
</pre>


<h2>Using RewriteMap in httpd.conf</h2>
<p>This is technically a faster way to do this, but it has to be in the <code>httpd.conf</code> file, not <code>.htaccess</code></p>
<pre>RewriteEngine on
RewriteBase /
RewriteMap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]</pre>


<h2>Using mod_speling in httpd.conf</h2>
<p>You can check out enabling the <a href="http://httpd.apache.org/docs/2.2/mod/mod_speling.html">mod_speling</a> apache module also.  I personally don't use it, but many people love it.</p>
<pre>
&lt;IfModule mod_speling.c&gt;
CheckCaseOnly On
CheckSpelling On
&lt;/IfModule&gt;
</pre><p><a rel="follow" href="http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html"></a> &hellip;<a href="http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html">Htaccess Rewrite for Redirecting Uppercase to Lowercase</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html">Htaccess Rewrite for Redirecting Uppercase to Lowercase</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/KzHYJf13omY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/htaccess/rewrite-uppercase-lowercase.html</feedburner:origLink></item>
		<item>
		<title>Separate favicons for the Frontend and Backend</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/1jrjrgjEvdw/favicon-frontend-backend.html</link>
		<comments>http://www.askapache.com/wordpress/favicon-frontend-backend.html#comments</comments>
		<pubDate>Tue, 30 Apr 2013 07:25:11 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8855</guid>
		<description><![CDATA[<p><p>Here's a nifty little idea I had that has some merit and is super easy. Separate favicons for separate areas of a site.  Basically, I can't live without Firefox or Chrome and the way they use multiple tabs, having about 20-50 open at any one time.. But that makes it more difficult to find the right tab! <br /><br /><a href="http://www.askapache.com/wordpress/favicon-frontend-backend.html"><img src="http://uploads.askapache.com/2013/04/favicon-tabs.png" alt="favicon-tabs" width="375" height="33" /></a></p></p><p>The post <a href="http://www.askapache.com/wordpress/favicon-frontend-backend.html">Separate favicons for the Frontend and Backend</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/wordpress/favicon-frontend-backend.html"></a><a href="http://www.askapache.com/wordpress/favicon-frontend-backend.html"><cite>AskApache.com</cite></a></p><p>Here's a nifty little idea I had that has some merit. Separate favicons for separate areas of a site.  Basically, I can't live without Firefox or Chrome and the way they use multiple tabs. <br /><br /><a href="http://uploads.askapache.com/2013/04/favicon-tabs.png"><img src="http://uploads.askapache.com/2013/04/favicon-tabs.png" alt="Separate favicons for the Frontend and Backend" width="375" height="33" title="favicon tabs" /></a><br /><br /> I usually have several tabs open for a single site.  Some tabs are in the backend, usually meaning WordPress administration area, and others are in the frontend, meaning the homepage or viewing a post.  I'm constantly going back and forth between tabs, often to edit a post, and then switch to the preview of the post.  Now, with 50 tabs open at one time, which isn't very unusual for me, it can become difficult to quickly spot which tab is which.  Solution?  Create 2 favicons.  One for the frontend, and a different one for the backend!  This makes it soooo much easier to quickly switch to the correct tab, and even though it's a fairly small trick/tip compared to most of the articles on this site, it's helpful enough that I wanted to put it out there for all you wonderful readers.<br class="C" /></p>

<h2>Separate favicons using WordPress</h2>
<p>So there are many ways to do this, but probably the best is to just add a simple little function to your themes <code>functions.php</code> file.</p>

<p>Just add this to your <code>functions.php</code> file.  Then you will need to create a favicon in your root folder where your <code>wp-config.php</code> file lives, and an admin-favicon.ico in your active themes folder where your <code>style.css</code> file lives.</p>
<p>View <a href="http://www.askapache.com/pub/php/askapache_separate_favicons.php">syntax-highlighted source</a>.</p>
<div>
<span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">askapache_separate_favicons</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;default&nbsp;for&nbsp;frontend<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$favicon_uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">WP_SITEURL&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'/favicon.ico'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;if&nbsp;in&nbsp;backend&nbsp;change&nbsp;to&nbsp;the&nbsp;admin-favicon.ico&nbsp;file&nbsp;located&nbsp;in&nbsp;the&nbsp;active&nbsp;theme&nbsp;directory&nbsp;where&nbsp;style.css&nbsp;is<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(&nbsp;</span><span style="color: #0000BB">is_admin</span><span style="color: #007700">()&nbsp;)&nbsp;</span><span style="color: #0000BB">$favicon_uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg_replace</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'|https?://[^/]+|i'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">get_stylesheet_directory_uri</span><span style="color: #007700">()&nbsp;)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/admin-favicon.ico'</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;output&nbsp;the&nbsp;xhtml<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'&lt;link&nbsp;rel="shortcut&nbsp;icon"&nbsp;href="'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$favicon_uri&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'"&nbsp;type="image/x-icon"&nbsp;/&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />}<br /></span><span style="color: #0000BB">add_action</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'wp_head'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'askapache_separate_favicons'&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">add_action</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'admin_head'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'askapache_separate_favicons'&nbsp;</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span></div>

<h2>Raw Code</h2>
<pre>
&lt;?php
&nbsp;
function askapache_separate_favicons() {
  
  // default for frontend
  $favicon_uri = WP_SITEURL . &#039;/favicon.ico&#039;;
  
  // if in backend change to the admin-favicon.ico file located in the active theme directory where style.css is
  if ( is_admin() ) $favicon_uri = preg_replace( &#039;|https?://[^/]+|i&#039;, &#039;&#039;, get_stylesheet_directory_uri() ) . &#039;/admin-favicon.ico&#039;;
&nbsp;
  // output the xhtml
  echo &#039;&lt;link rel="shortcut icon" href="&#039; . $favicon_uri . &#039;" type="image/x-icon" /&gt;&#039;;
  
}
add_action( &#039;wp_head&#039;, &#039;askapache_separate_favicons&#039; );
add_action( &#039;admin_head&#039;, &#039;askapache_separate_favicons&#039; );
&nbsp;
?&gt;
</pre><p><a rel="follow" href="http://www.askapache.com/wordpress/favicon-frontend-backend.html"></a> &hellip;<a href="http://www.askapache.com/wordpress/favicon-frontend-backend.html">Separate favicons for the Frontend and Backend</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/wordpress/favicon-frontend-backend.html">Separate favicons for the Frontend and Backend</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/1jrjrgjEvdw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/wordpress/favicon-frontend-backend.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/wordpress/favicon-frontend-backend.html</feedburner:origLink></item>
		<item>
		<title>PHP fsockopen for FAST DNS lookups over UDP</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/gu3FRKnvGkg/php-fsockopen-dns-udp.html</link>
		<comments>http://www.askapache.com/php/php-fsockopen-dns-udp.html#comments</comments>
		<pubDate>Sun, 28 Apr 2013 17:03:39 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[fsockopen]]></category>
		<category><![CDATA[gethostbyaddr]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[OpenDNS]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[udp]]></category>
		<category><![CDATA[UltraDNS]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8835</guid>
		<description><![CDATA[<p><p>While reading up on gethostbyaddr on PHP.net, I saw a nice idea for using fsockopen to connect over UDP port 53 to any Public DNS server, like Google DNS <code>8.8.8.8</code>, and sending the reverse addr lookup in oh about 100 bytes, then getting the response in oh about 150 bytes!  All in less than a second.  This is how/why to read/write data directly to the wire!  This would be extremely valuable for use in things like my <a href="http://www.askapache.com/online-tools/http-headers-tool/">online header tool</a> because it's faster than any other method.  As usual, I went a bit overboard optimizing it to be lean and fast.</p></p><p>The post <a href="http://www.askapache.com/php/php-fsockopen-dns-udp.html">PHP fsockopen for FAST DNS lookups over UDP</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/php/php-fsockopen-dns-udp.html"></a><a href="http://www.askapache.com/php/php-fsockopen-dns-udp.html"><cite>AskApache.com</cite></a></p><p>While reading up on gethostbyaddr on PHP.net, I saw a <a href="http://www.php.net/manual/en/function.gethostbyaddr.php#46869">nice idea</a> for using fsockopen to connect over UDP port 53 to any Public DNS server, like Google's <code>8.8.8.8</code>, and sending the reverse addr lookup in oh about 100 bytes, then getting the response in oh about 150 bytes!  All in less than a second.  This would be extremely valuable for use in things like my <a href="http://www.askapache.com/online-tools/http-headers-tool/">online header tool</a> because it's faster than any other method.  As usual, I went a bit overboard optimizing it to be lean and fast.</p>
<p>It's also a fairly decent example of how to use fsockopen in general.. <a href="http://www.php.net/manual/en/function.fsockopen.php">Fsockopen</a> enables super-hero-like tricks.</p>

<h2>PHP fsockopen for DNS lookups</h2>
<p>The function has 3 arguments.</p>
<ul>
<li>An ip address to lookup.</li>
<li>A DNS server to query.</li>
<li>And a timeout in seconds.</li>
</ul>

<h3>Using the 6 fastest DNS servers</h3>
<p>This list includes OpenDNS, UltraDNS, Level3, RoadRunner, and of course, Google DNS (see wikipedia for more).</p>
<pre>
$ip = &#039;208.86.158.195&#039;;
foreach ( array(&#039;8.8.8.8&#039;, &#039;156.154.70.1&#039;, &#039;208.67.222.222&#039;, &#039;156.154.70.1&#039;, &#039;209.244.0.4&#039;, &#039;216.146.35.35&#039;) as $dns) {
  echo gethostbyaddr_timeout( $ip, $dns, 1 );
}
</pre>


<h2>The gethostbyaddr source</h2>
<p>View the <a href="http://www.askapache.com/pub/php/gethostbyaddr.php">syntax highlighted source</a>.</p>
<div><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">gethostbyaddr_timeout</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$ip</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dns</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$timeout&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">3&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;random&nbsp;transaction&nbsp;number&nbsp;(for&nbsp;routers&nbsp;etc&nbsp;to&nbsp;get&nbsp;the&nbsp;reply&nbsp;back)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rand</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">77&nbsp;</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\1\0\0\1\0\0\0\0\0\0"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;octals&nbsp;in&nbsp;the&nbsp;array,&nbsp;keys&nbsp;are&nbsp;strlen&nbsp;of&nbsp;bit<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$bitso&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">""</span><span style="color: #007700">,</span><span style="color: #DD0000">"\1"</span><span style="color: #007700">,</span><span style="color: #DD0000">"\2"</span><span style="color: #007700">,</span><span style="color: #DD0000">"\3"&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach(&nbsp;</span><span style="color: #0000BB">array_reverse</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">explode</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'.'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$ip&nbsp;</span><span style="color: #007700">)&nbsp;)&nbsp;as&nbsp;</span><span style="color: #0000BB">$bit&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$l</span><span style="color: #007700">=</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$bit</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">.=</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$bitso</span><span style="color: #007700">[</span><span style="color: #0000BB">$l</span><span style="color: #007700">]}</span><span style="color: #DD0000">"</span><span style="color: #007700">.</span><span style="color: #0000BB">$bit</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;and&nbsp;the&nbsp;final&nbsp;bit&nbsp;of&nbsp;the&nbsp;request<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"\7in-addr\4arpa\0\0\x0C\0\1"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;create&nbsp;UDP&nbsp;socket<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$errno&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$errstr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fsockopen</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"udp://</span><span style="color: #007700">{</span><span style="color: #0000BB">$dns</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">53</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errstr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$timeout&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;!&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">||&nbsp;!&nbsp;</span><span style="color: #0000BB">is_resource</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">)&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$errno</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'socket_set_timeout'&nbsp;</span><span style="color: #007700">)&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">socket_set_timeout</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$timeout&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;(&nbsp;</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'stream_set_timeout'&nbsp;</span><span style="color: #007700">)&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">stream_set_timeout</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$timeout&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;send&nbsp;our&nbsp;request&nbsp;(and&nbsp;store&nbsp;request&nbsp;size&nbsp;so&nbsp;we&nbsp;can&nbsp;cheat&nbsp;later)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$requestsize&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$max_rx&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$requestsize&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$start&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">time</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$responsesize&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(&nbsp;</span><span style="color: #0000BB">$received&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$max_rx&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;(&nbsp;(&nbsp;</span><span style="color: #0000BB">time</span><span style="color: #007700">()&nbsp;-&nbsp;</span><span style="color: #0000BB">$start&nbsp;</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">$timeout&nbsp;</span><span style="color: #007700">)&nbsp;&amp;&amp;&nbsp;(</span><span style="color: #0000BB">$buf&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fread</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1&nbsp;</span><span style="color: #007700">)&nbsp;)&nbsp;!==&nbsp;</span><span style="color: #0000BB">false&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$responsesize</span><span style="color: #007700">++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #0000BB">$buf</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;//echo&nbsp;</span><span style="color: #DD0000">"[tx:&nbsp;</span><span style="color: #0000BB">$requestsize</span><span style="color: #DD0000">&nbsp;bytes]&nbsp;&nbsp;[rx:&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$responsesize</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;bytes]"</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;hope&nbsp;we&nbsp;get&nbsp;a&nbsp;reply<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(&nbsp;</span><span style="color: #0000BB">is_resource</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">)&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">fclose</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;if&nbsp;empty&nbsp;response&nbsp;or&nbsp;bad&nbsp;response,&nbsp;return&nbsp;original&nbsp;ip<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(&nbsp;empty(&nbsp;</span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">)&nbsp;||&nbsp;</span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$response</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$requestsize&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2&nbsp;</span><span style="color: #007700">)&nbsp;)&nbsp;!=&nbsp;</span><span style="color: #DD0000">'000c'&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$ip</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;set&nbsp;up&nbsp;our&nbsp;variables<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$host&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$len&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$loops&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;set&nbsp;our&nbsp;pointer&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the&nbsp;hostname&nbsp;uses&nbsp;the&nbsp;request&nbsp;size&nbsp;from&nbsp;earlier&nbsp;rather&nbsp;than&nbsp;work&nbsp;it&nbsp;out<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$pos&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$requestsize&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;do&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;get&nbsp;segment&nbsp;size<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$len&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">unpack</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'c'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$response</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pos</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1&nbsp;</span><span style="color: #007700">)&nbsp;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;null&nbsp;terminated&nbsp;string,&nbsp;so&nbsp;length&nbsp;0&nbsp;=&nbsp;finished&nbsp;-&nbsp;return&nbsp;the&nbsp;hostname,&nbsp;without&nbsp;the&nbsp;trailing&nbsp;.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(&nbsp;</span><span style="color: #0000BB">$len</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #0000BB">0&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$host</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;add&nbsp;segment&nbsp;to&nbsp;our&nbsp;host<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$host&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$response</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pos&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$len</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;)&nbsp;.&nbsp;</span><span style="color: #DD0000">'.'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;move&nbsp;pointer&nbsp;on&nbsp;to&nbsp;the&nbsp;next&nbsp;segment<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$pos&nbsp;</span><span style="color: #007700">+=&nbsp;</span><span style="color: #0000BB">$len</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;+&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;recursion&nbsp;protection<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$loops</span><span style="color: #007700">++;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(&nbsp;</span><span style="color: #0000BB">$len</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;!=&nbsp;</span><span style="color: #0000BB">0&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">$loops&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">20&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;return&nbsp;the&nbsp;ip&nbsp;in&nbsp;case&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">return&nbsp;</span><span style="color: #0000BB">$ip</span><span style="color: #007700">;<br />}<br /><br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</div>


<h2>Download and Copy Code</h2>
<p>Or download from: <a href="http://uploads.askapache.com/2013/04/gethostbyaddr.txt">gethostbyaddr.txt</a></p> 
<pre>function gethostbyaddr_timeout( $ip, $dns, $timeout = 3 ) {
  // idea from http://www.php.net/manual/en/function.gethostbyaddr.php#46869
  // http://www.askapache.com/pub/php/gethostbyaddr.php
  
    // random transaction number (for routers etc to get the reply back)
    $data = rand( 10, 77 ) . "\1\0\0\1\0\0\0\0\0\0";
  
  // octals in the array, keys are strlen of bit
  $bitso = array("","\1","\2","\3" );
  foreach( array_reverse( explode( &#039;.&#039;, $ip ) ) as $bit ) {
    $l=strlen($bit);
    $data.="{$bitso[$l]}".$bit;
  }
  
    // and the final bit of the request
  $data .= "\7in-addr\4arpa\0\0\x0C\0\1";
    
    // create UDP socket
  $errno = $errstr = 0;
    $fp = fsockopen( "udp://{$dns}", 53, $errno, $errstr, $timeout );
  if( ! $fp || ! is_resource( $fp ) )
    return $errno;
&nbsp;
  if( function_exists( &#039;socket_set_timeout&#039; ) ) {
    socket_set_timeout( $fp, $timeout );
  } elseif ( function_exists( &#039;stream_set_timeout&#039; ) ) {
    stream_set_timeout( $fp, $timeout );
  }
&nbsp;
    // send our request (and store request size so we can cheat later)
    $requestsize = fwrite( $fp, $data );
  $max_rx = $requestsize * 3;
  
  $start = time();
  $responsesize = 0;
  while ( $responsesize &lt; $max_rx &amp;&amp; ( ( time() - $start ) &lt; $timeout ) &amp;&amp; ($buf = fread( $fp, 1 ) ) !== false ) {
    $responsesize++;
    $response .= $buf;
  }
  // echo "[tx: $requestsize bytes]  [rx: {$responsesize} bytes]";
&nbsp;
    // hope we get a reply
    if ( is_resource( $fp ) )
    fclose( $fp );
&nbsp;
  // if empty response or bad response, return original ip
    if ( empty( $response ) || bin2hex( substr( $response, $requestsize + 2, 2 ) ) != &#039;000c&#039; )
    return $ip;
    
  // set up our variables
  $host = &#039;&#039;;
  $len = $loops = 0;
  
  // set our pointer at the beginning of the hostname uses the request size from earlier rather than work it out
  $pos = $requestsize + 12;
  do {
    // get segment size
    $len = unpack( &#039;c&#039;, substr( $response, $pos, 1 ) );
    
    // null terminated string, so length 0 = finished - return the hostname, without the trailing .
    if ( $len[1] == 0 )
      return substr( $host, 0, -1 );
      
    // add segment to our host
    $host .= substr( $response, $pos + 1, $len[1] ) . &#039;.&#039;;
    
    // move pointer on to the next segment
    $pos += $len[1] + 1;
    
    // recursion protection
    $loops++;
  }
  while ( $len[1] != 0 &amp;&amp; $loops &lt; 20 );
  
  // return the ip in case 
  return $ip;
}
</pre><p><a rel="follow" href="http://www.askapache.com/php/php-fsockopen-dns-udp.html"></a> &hellip;<a href="http://www.askapache.com/php/php-fsockopen-dns-udp.html">PHP fsockopen for FAST DNS lookups over UDP</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/php/php-fsockopen-dns-udp.html">PHP fsockopen for FAST DNS lookups over UDP</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/gu3FRKnvGkg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/php/php-fsockopen-dns-udp.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.askapache.com/php/php-fsockopen-dns-udp.html</feedburner:origLink></item>
		<item>
		<title>Bash Functions and Aliases for Traps, Kills, and Signals</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/oMFJaXzNCqI/bash-traps-kills-signals.html</link>
		<comments>http://www.askapache.com/shellscript/bash-traps-kills-signals.html#comments</comments>
		<pubDate>Fri, 26 Apr 2013 07:31:47 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[kill]]></category>
		<category><![CDATA[trap]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8477</guid>
		<description><![CDATA[<p><p>Bash Functions and Aliases for Traps, Kills, and Signals.  Useful for translating signal numbers/signal names and getting more info about signals.</p></p><p>The post <a href="http://www.askapache.com/shellscript/bash-traps-kills-signals.html">Bash Functions and Aliases for Traps, Kills, and Signals</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/shellscript/bash-traps-kills-signals.html"></a><a href="http://www.askapache.com/shellscript/bash-traps-kills-signals.html"><cite>AskApache.com</cite></a></p><p>Download: <a href="http://uploads.askapache.com/2013/04/trapstuff.txt">trapstuff.txt</a></p>
<p>See also: <code>signal.h</code></p>

<h2>Bash Trap and Kill Aliases</h2>
<pre>
alias traps=&#039;trap -l|sed "s,\t,\n,g;s,),:,g;s,SIG,,g;s, \([0-9]\),\1,g"&#039;
alias kills=&#039;for h in $(builtin kill -l); do echo "$(builtin kill -l $h): $h"; done&#039;;
</pre>

<h3>traps output</h3>
<pre>
1: HUP
2: INT
3: QUIT
4: ILL
5: TRAP
6: ABRT
7: BUS
8: FPE
9: KILL
10: USR1
11: SEGV
12: USR2
13: PIPE
14: ALRM
15: TERM
16: STKFLT
17: CHLD
18: CONT
19: STOP
20: TSTP
21: TTIN
22: TTOU
23: URG
24: XCPU
25: XFSZ
26: VTALRM
27: PROF
28: WINCH
29: IO
30: PWR
31: SYS
34: RTMIN
35: RTMIN+1
36: RTMIN+2
37: RTMIN+3
38: RTMIN+4
39: RTMIN+5
40: RTMIN+6
41: RTMIN+7
42: RTMIN+8
43: RTMIN+9
44: RTMIN+10
45: RTMIN+11
46: RTMIN+12
47: RTMIN+13
48: RTMIN+14
49: RTMIN+15
50: RTMAX-14
51: RTMAX-13
52: RTMAX-12
53: RTMAX-11
54: RTMAX-10
55: RTMAX-9
56: RTMAX-8
57: RTMAX-7
58: RTMAX-6
59: RTMAX-5
60: RTMAX-4
61: RTMAX-3
62: RTMAX-2
63: RTMAX-1
64: RTMAX</pre>


<h2>Trap and Kill Functions</h2>
<p>Using traps are helpful to use in functions like this:</p>
<pre>
function yn ()
{ 
  local post=`tput op;tput sgr0;tput cnorm`;
  trap &#039;echo -e "${post}"&#039; 1 2 3 6 15 RETURN;
  (
    local a= YN=1 msg="${@}" pre=`tput civis;tput setab 4;tput setaf 7` post=`tput op;tput sgr0;tput cnorm`;
    trap &#039;echo -e "${post}"&#039; 1 2 3 6 15 RETURN;
    until [[ $YN == 0 || $YN == 65 ]]; do
      echo -en "\n\n${pre}:: ${msg}? (y/N)${post} " &amp;&amp; read -s -n 1 a;
      case $a in 
        [yY]) YN=0;
        ;;
        [nN]) YN=65;
        ;;
      esac;
      echo;
    done;
    return $YN
  )
}
</pre>

<h3>Info about a Signal number or name</h3>
<pre>
function trapinfo () 
{ 
   local signum=${1:-} sigdesc="`trapdesc ${1:-}`";
   case $signum in 
    1 | HUP | SIGHUP) echo "${signum}: ${sigdesc}: HUP - SIGHUP"
     ;;
    2 | INT | SIGINT) echo "${signum}: ${sigdesc}: INT - SIGINT"
     ;;
    3 | QUIT | SIGQUIT) echo "${signum}: ${sigdesc}: QUIT - SIGQUIT"
     ;;
    4 | ILL | SIGILL) echo "${signum}: ${sigdesc}: ILL - SIGILL"
     ;;
    5 | TRAP | SIGTRAP) echo "${signum}: ${sigdesc}: TRAP - SIGTRAP"
     ;;
    6 | ABRT | SIGABRT) echo "${signum}: ${sigdesc}: ABRT - SIGABRT"
     ;;
    7 | BUS | SIGBUS) echo "${signum}: ${sigdesc}: BUS - SIGBUS"
     ;;
    8 | FPE | SIGFPE) echo "${signum}: ${sigdesc}: FPE - SIGFPE"
     ;;
    9 | KILL | SIGKILL) echo "${signum}: ${sigdesc}: KILL - SIGKILL"
     ;;
    10 | USR1 | SIGUSR1) echo "${signum}: ${sigdesc}: USR1 - SIGUSR1"
     ;;
    11 | SEGV | SIGSEGV) echo "${signum}: ${sigdesc}: SEGV - SIGSEGV"
     ;;
    12 | USR2 | SIGUSR2) echo "${signum}: ${sigdesc}: USR2 - SIGUSR2"
     ;;
    13 | PIPE | SIGPIPE) echo "${signum}: ${sigdesc}: PIPE - SIGPIPE"
     ;;
    14 | ALRM | SIGALRM) echo "${signum}: ${sigdesc}: ALRM - SIGALRM"
     ;;
    15 | TERM | SIGTERM) echo "${signum}: ${sigdesc}: TERM - SIGTERM"
     ;;
    16 | STKFLT | SIGSTKFLT) echo "${signum}: ${sigdesc}: STKFLT - SIGSTKFLT"
     ;;
    17 | CHLD | SIGCHLD) echo "${signum}: ${sigdesc}: CHLD - SIGCHLD"
     ;;
    18 | CONT | SIGCONT) echo "${signum}: ${sigdesc}: CONT - SIGCONT"
     ;;
    19 | STOP | SIGSTOP) echo "${signum}: ${sigdesc}: STOP - SIGSTOP"
     ;;
    20 | TSTP | SIGTSTP) echo "${signum}: ${sigdesc}: TSTP - SIGTSTP"
     ;;
    21 | TTIN | SIGTTIN) echo "${signum}: ${sigdesc}: TTIN - SIGTTIN"
     ;;
    22 | TTOU | SIGTTOU) echo "${signum}: ${sigdesc}: TTOU - SIGTTOU"
     ;;
    23 | URG | SIGURG) echo "${signum}: ${sigdesc}: URG - SIGURG"
     ;;
    24 | XCPU | SIGXCPU) echo "${signum}: ${sigdesc}: XCPU - SIGXCPU"
     ;;
    25 | XFSZ | SIGXFSZ) echo "${signum}: ${sigdesc}: XFSZ - SIGXFSZ"
     ;;
    26 | VTALRM | SIGVTALRM) echo "${signum}: ${sigdesc}: VTALRM - SIGVTALRM"
     ;;
    27 | PROF | SIGPROF) echo "${signum}: ${sigdesc}: PROF - SIGPROF"
     ;;
    28 | WINCH | SIGWINCH) echo "${signum}: ${sigdesc}: WINCH - SIGWINCH"
     ;;
    29 | IO | SIGIO) echo "${signum}: ${sigdesc}: IO - SIGIO"
     ;;
    30 | PWR | SIGPWR) echo "${signum}: ${sigdesc}: PWR - SIGPWR"
     ;;
    31 | SYS | SIGSYS) echo "${signum}: ${sigdesc}: SYS - SIGSYS"
     ;;
    34 | RTMIN | SIGRTMIN) echo "${signum}: ${sigdesc}: RTMIN - SIGRTMIN"
     ;;
    35 | RTMIN+1 | SIGRTMIN+1) echo "${signum}: ${sigdesc}: RTMIN+1 - SIGRTMIN+1"
     ;;
    36 | RTMIN+2 | SIGRTMIN+2) echo "${signum}: ${sigdesc}: RTMIN+2 - SIGRTMIN+2"
     ;;
    37 | RTMIN+3 | SIGRTMIN+3) echo "${signum}: ${sigdesc}: RTMIN+3 - SIGRTMIN+3"
     ;;
    38 | RTMIN+4 | SIGRTMIN+4) echo "${signum}: ${sigdesc}: RTMIN+4 - SIGRTMIN+4"
     ;;
    39 | RTMIN+5 | SIGRTMIN+5) echo "${signum}: ${sigdesc}: RTMIN+5 - SIGRTMIN+5"
     ;;
    40 | RTMIN+6 | SIGRTMIN+6) echo "${signum}: ${sigdesc}: RTMIN+6 - SIGRTMIN+6"
     ;;
    41 | RTMIN+7 | SIGRTMIN+7) echo "${signum}: ${sigdesc}: RTMIN+7 - SIGRTMIN+7"
     ;;
    42 | RTMIN+8 | SIGRTMIN+8) echo "${signum}: ${sigdesc}: RTMIN+8 - SIGRTMIN+8"
     ;;
    43 | RTMIN+9 | SIGRTMIN+9) echo "${signum}: ${sigdesc}: RTMIN+9 - SIGRTMIN+9"
     ;;
    44 | RTMIN+10 | SIGRTMIN+10) echo "${signum}: ${sigdesc}: RTMIN+10 - SIGRTMIN+10"
     ;;
    45 | RTMIN+11 | SIGRTMIN+11) echo "${signum}: ${sigdesc}: RTMIN+11 - SIGRTMIN+11"
     ;;
    46 | RTMIN+12 | SIGRTMIN+12) echo "${signum}: ${sigdesc}: RTMIN+12 - SIGRTMIN+12"
     ;;
    47 | RTMIN+13 | SIGRTMIN+13) echo "${signum}: ${sigdesc}: RTMIN+13 - SIGRTMIN+13"
     ;;
    48 | RTMIN+14 | SIGRTMIN+14) echo "${signum}: ${sigdesc}: RTMIN+14 - SIGRTMIN+14"
     ;;
    49 | RTMIN+15 | SIGRTMIN+15) echo "${signum}: ${sigdesc}: RTMIN+15 - SIGRTMIN+15"
     ;;
    50 | RTMAX-14 | SIGRTMAX-14) echo "${signum}: ${sigdesc}: RTMAX-14 - SIGRTMAX-14"
     ;;
    51 | RTMAX-13 | SIGRTMAX-13) echo "${signum}: ${sigdesc}: RTMAX-13 - SIGRTMAX-13"
     ;;
    52 | RTMAX-12 | SIGRTMAX-12) echo "${signum}: ${sigdesc}: RTMAX-12 - SIGRTMAX-12"
     ;;
    53 | RTMAX-11 | SIGRTMAX-11) echo "${signum}: ${sigdesc}: RTMAX-11 - SIGRTMAX-11"
     ;;
    54 | RTMAX-10 | SIGRTMAX-10) echo "${signum}: ${sigdesc}: RTMAX-10 - SIGRTMAX-10"
     ;;
    55 | RTMAX-9 | SIGRTMAX-9) echo "${signum}: ${sigdesc}: RTMAX-9 - SIGRTMAX-9"
     ;;
    56 | RTMAX-8 | SIGRTMAX-8) echo "${signum}: ${sigdesc}: RTMAX-8 - SIGRTMAX-8"
     ;;
    57 | RTMAX-7 | SIGRTMAX-7) echo "${signum}: ${sigdesc}: RTMAX-7 - SIGRTMAX-7"
     ;;
    58 | RTMAX-6 | SIGRTMAX-6) echo "${signum}: ${sigdesc}: RTMAX-6 - SIGRTMAX-6"
     ;;
    59 | RTMAX-5 | SIGRTMAX-5) echo "${signum}: ${sigdesc}: RTMAX-5 - SIGRTMAX-5"
     ;;
    60 | RTMAX-4 | SIGRTMAX-4) echo "${signum}: ${sigdesc}: RTMAX-4 - SIGRTMAX-4"
     ;;
    61 | RTMAX-3 | SIGRTMAX-3) echo "${signum}: ${sigdesc}: RTMAX-3 - SIGRTMAX-3"
     ;;
    62 | RTMAX-2 | SIGRTMAX-2) echo "${signum}: ${sigdesc}: RTMAX-2 - SIGRTMAX-2"
     ;;
    63 | RTMAX-1 | SIGRTMAX-1) echo "${signum}: ${sigdesc}: RTMAX-1 - SIGRTMAX-1"
     ;;
    64 | RTMAX | SIGRTMAX) echo "${signum}: ${sigdesc}: RTMAX - SIGRTMAX"
     ;;
    65) echo "${signum}: ${sigdesc}: invalid signal specification"
     ;;
    *) echo "${signum}: ${sigdesc}: Unknown Signal"
     ;;
   esac
}
</pre>


<h3>Function to describe the signal</h3>
<pre>
function trapdesc () 
{ 
   case $1 in 
    0) echo "Bogus signal"
     ;;
    1) echo "Hangup"
     ;;
    2) echo "Interrupt"
     ;;
    3) echo "Quit"
     ;;
    4) echo "Illegal instruction"
     ;;
    5) echo "BPT trace/trap"
     ;;
    6) echo "ABORT instruction"
     ;;
    7) echo "Bus error"
     ;;
    8) echo "Floating point exception"
     ;;
    9) echo "Killed"
     ;;
    10) echo "User signal 1"
     ;;
    11) echo "Segmentation fault"
     ;;
    12) echo "User signal 2"
     ;;
    13) echo "Broken pipe"
     ;;
    14) echo "Alarm clock"
     ;;
    15) echo "Terminated"
     ;;
    17) echo "Child death or stop"
     ;;
    18) echo "Continue"
     ;;
    19) echo "Stopped (signal)"
     ;;
    20) echo "Stopped"
     ;;
    21) echo "Stopped (tty input)"
     ;;
    22) echo "Stopped (tty output)"
     ;;
    23) echo "Urgent IO condition"
     ;;
    24) echo "CPU limit"
     ;;
    25) echo "File limit"
     ;;
    26) echo "Alarm (virtual)"
     ;;
    27) echo "Alarm (profile)"
     ;;
    28) echo "Window changed"
     ;;
    29) echo "I/O ready"
     ;;
    30) echo "power failure imminent"
     ;;
    31) echo "Bad system call"
     ;;
    *) echo "Unknown"
     ;;
   esac
}
</pre><p><a rel="follow" href="http://www.askapache.com/shellscript/bash-traps-kills-signals.html"></a> &hellip;<a href="http://www.askapache.com/shellscript/bash-traps-kills-signals.html">Bash Functions and Aliases for Traps, Kills, and Signals</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/shellscript/bash-traps-kills-signals.html">Bash Functions and Aliases for Traps, Kills, and Signals</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/oMFJaXzNCqI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/shellscript/bash-traps-kills-signals.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/shellscript/bash-traps-kills-signals.html</feedburner:origLink></item>
		<item>
		<title>Bash Script to Create index.html of Dir Listing</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/baYot_kyVL4/bash-script-create-index-html-dir-listing.html</link>
		<comments>http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html#comments</comments>
		<pubDate>Thu, 25 Apr 2013 21:59:46 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[DirectoryIndex]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[IndexOptions]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8450</guid>
		<description><![CDATA[<p><p><img class="IFL" src="http://uploads.askapache.com/2013/04/bash-generated-index-listing-300x96.png" alt="bash-generated-index-listing" width="300" height="96" />If you use Apache to auto-generate directory index listings of files/dirs, and you have a large number of files and directories in the root directory and/or slow IO speed, then generating the index could take Apache over a minute!<br class="C" /></p></p><p>The post <a href="http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html">Bash Script to Create index.html of Dir Listing</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html"></a><a href="http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html"><cite>AskApache.com</cite></a></p><p><a class="IFL" href="http://uploads.askapache.com/2013/04/bash-generated-index-listing.png"><img src="http://uploads.askapache.com/2013/04/bash-generated-index-listing-300x96.png" alt="Bash Script to Create index.html of Dir Listing" width="300" height="96" title="bash generated index listing" /></a>If you use Apache to auto-generate directory index listings of files/dirs, using the <code>IndexOptions</code> directive, like at <a href="http://gnu.askapache.com/">http://gnu.askapache.com/</a>, and you have a large number of files and directories in the root directory and/or slow IO speed, then generating the index could take Apache over a minute!<br class="C" /></p>


<h2>Fix for index Listings</h2>
<p>I fixed that by writing a bash shell script, which is run by cron, in this case immediately after every rsync.  This creates a static <code>index.html</code> file formatted exactly as the simple apache-generated one.  Now apache serves the single <code>index.html</code>, which can be cached.  <strong>Served in less than a second now.</strong></p>

<h2>Htaccess for Indexes</h2>
<p>Here is the basic <a href="http://www.askapache.com/htaccess/htaccess.html" title="Htaccess Files">.htaccess</a> to setup in the root directory.</p>
<pre>
Options SymLinksIfOwnerMatch Indexes
&nbsp;
DirectoryIndex index.html
IndexOptions FancyIndexing TrackModified IgnoreClient ScanHTMLTitles SuppressRules VersionSort IgnoreCase NameWidth=* DescriptionWidth=*
</pre>

<h2>Shell Script to create index.html</h2>
<p>The source is below, or download it: <a href="http://uploads.askapache.com/2013/04/gnu-mirror-index-creator.txt">mirror index.html creator</a>.</p>
<pre>
#!/bin/bash
# Updated: Wed Apr 10 21:04:12 2013 by webmaster@askapache
# @ http://uploads.askapache.com/2013/04/gnu-mirror-index-creator.txt
# Copyright (C) 2013 Free Software Foundation, Inc.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
&nbsp;
function create_gnu_index ()
{
    # call it right or die
    [[ $# != 3 ]] &amp;&amp; echo "bad args. do: $FUNCNAME &#039;/DOCUMENT_ROOT/&#039; &#039;/&#039; &#039;gnu.askapache.com&#039;" &amp;&amp; exit 2
  
    # D is the doc_root containing the site
    local L= D="$1" SUBDIR="$2" DOMAIN="$3" F=
&nbsp;
    # The index.html file to create
    F="${D}index.html"
&nbsp;
    # if dir doesnt exist, create it
    [[ -d $D ]] || mkdir -p $D;
&nbsp;
    # cd into dir or die
    cd $D || exit 2;
&nbsp;
    # touch index.html and check if writable or die
    touch $F &amp;&amp; test -w $F || exit 2;
&nbsp;
    # remove empty directories, they dont need to be there and slow things down if they are
    find . -maxdepth 1 -type d -empty -exec rm -rf {} \;
&nbsp;
    # start of total output for saving as index.html
    (
&nbsp;
        # print the html header
        echo &#039;&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&gt;&#039;;
        echo "&lt;html&gt;&lt;head&gt;&lt;title&gt;Index of http://${DOMAIN}${SUBDIR}&lt;/title&gt;&lt;/head&gt;";
        echo "&lt;body&gt;&lt;h1&gt;Index of ${SUBDIR}&lt;/h1&gt;&lt;pre&gt;      Name                                        Last modified      Size";
&nbsp;
        # start of content output
        (
            # change IFS locally within subshell so the for loop saves line correctly to L var
            IFS=$&#039;\n&#039;;
&nbsp;
            # pretty sweet, will mimick the normal apache output
            for L in $(find -L . -mount -depth -maxdepth 1 -type f ! -name &#039;index.html&#039; -printf "      &lt;a href=\"%f\"&gt;%-44f@_@%Td-%Tb-%TY %Tk:%TM  @%f@\n"|sort|sed &#039;s,\([\ ]\+\)@_@,&lt;/a&gt;\1,g&#039;);
            do
                # file
                F=$(sed -e &#039;s,^.*@\([^@]\+\)@.*$,\1,g&#039;&lt;&lt;&lt;"$L");
&nbsp;
                # file with file size
                F=$(du -bh $F | cut -f1);
&nbsp;
                # output with correct format
                sed -e &#039;s,\ @.*$, &#039;"$F"&#039;,g&#039;&lt;&lt;&lt;"$L";
            done;
        )
&nbsp;
        # now output a list of all directories in this dir (maxdepth 1) other than &#039;.&#039; outputting in a sorted manner exactly like apache
        find -L . -mount -depth -maxdepth 1 -type d ! -name &#039;.&#039; -printf "      &lt;a href=\"%f\"&gt;%-43f@_@%Td-%Tb-%TY %Tk:%TM  -\n"|sort -d|sed &#039;s,\([\ ]\+\)@_@,/&lt;/a&gt;\1,g&#039;
&nbsp;
        # print the footer html
        echo "&lt;/pre&gt;&lt;address&gt;Apache Server at ${DOMAIN}&lt;/address&gt;&lt;/body&gt;&lt;/html&gt;";
&nbsp;
    # finally save the output of the subshell to index.html
    )  &gt; $F;
&nbsp;
}
&nbsp;
# start the run ( use function so everything is local and contained )
#    $1 is absolute document_root with trailing &#039;/&#039;
#    $2 is subdir like &#039;/subdir/&#039; if thats the web root, &#039;/&#039; if no subdir
#    $3 is the domain &#039;subdomain.domain.tld&#039;
create_gnu_index "${HOME}/sites/gnu.askapache.com/htdocs/" "/" "gnu.askapache.com"
&nbsp;
# takes about 1-5 seconds to complete
exit
</pre><p><a rel="follow" href="http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html"></a> &hellip;<a href="http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html">Bash Script to Create index.html of Dir Listing</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html">Bash Script to Create index.html of Dir Listing</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/baYot_kyVL4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/shellscript/bash-script-create-index-html-dir-listing.html</feedburner:origLink></item>
		<item>
		<title>HTTP Status Codes</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/zErbt4nFcBo/http-status-codes.html</link>
		<comments>http://www.askapache.com/net/http-status-codes.html#comments</comments>
		<pubDate>Sat, 06 Apr 2013 22:49:41 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Net]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[ErrorDocument]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Status Code]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8342</guid>
		<description><![CDATA[<p><p><a href="http://www.askapache.com/net/http-status-codes.html" class="IFL"><img src="http://uploads.askapache.com/2013/04/http-status-codes-tool-300x182.png" alt="http-status-codes-tool" width="300" height="182"  /></a>This is a big update from the last time I looked into this, when I enumerated <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">57 Status Codes</a> that Apache 2.x was capable of handling.  This list contains <a href="http://www.askapache.com/net/http-status-codes.html">83 Status Codes</a> recognized by Apache.  I compiled the latest 2.4.4 Apache in order to view the actual codes sent by a live server.. very cool.  You can read about the newest HTTP Status Codes in <a href="http://tools.ietf.org/html/rfc6585" title="Additional HTTP Status Codes">RFC 6585</a>.<br class="C" /></p></p><p>The post <a href="http://www.askapache.com/net/http-status-codes.html">HTTP Status Codes</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/net/http-status-codes.html"></a><a href="http://www.askapache.com/net/http-status-codes.html"><cite>AskApache.com</cite></a></p><p>This is a big update from the last time I looked into this, when I enumerated <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">57 Status Codes</a> that Apache 2.x was capable of handling.  This list contains <strong>83</strong> Status Codes that Apache recognizes.  I compiled the latest 2.4.4 Apache in order to view the actual codes sent by a live server.. very cool.  You can read about the newest HTTP Status Codes in <a href="http://tools.ietf.org/html/rfc6585" title="Additional HTTP Status Codes">RFC 6585</a>.</p>



<h2>HTTP Status Code Groups</h2>
<p>There are 4 main status code groups in Apache.  They represent all the status codes from 100 to 600.</p> 
<ol>
<li>1xx <strong>INFO</strong>: is the status code informational? <code>( x &gt;= 100 &amp;&amp; x &lt; 200 )</code></li>
<li>2xx <strong>SUCCESS</strong>: is the status code OK? <code>( x &gt;= 200 &amp;&amp; x &lt; 300 )</code></li>
<li>3xx <strong>REDIRECT</strong>: is the status code a redirect? <code>( x &gt;= 300 &amp;&amp; x &lt; 400 )</code></li>
<li>[45]xx <strong>ERROR</strong>: is the status code a error (client or server)? <code>( x &gt;= 400 &amp;&amp; x &lt; 600 )</code><ul>
	<li>4xx <strong>CLIENT_ERROR</strong>: is the status code a client error? <code>( x &gt;= 400 &amp;&amp; x &lt; 500 )</code></li>
	<li>5xx <strong>SERVER_ERROR</strong>: is the status code a server error? <code>( x &gt;= 500 &amp;&amp; x &lt; 600 )</code></li></ul></li>
</ol>
<p>Here is how <a href="http://www.iana.org/assignments/http-status-codes/http-status-codes.txt">IANA</a> defineds them.</p>
<h3>Status Code Groups</h3>
<dl><dt>1xx: Informational</dt><dd>Request received, continuing process</dd>
<dt>2xx: Success</dt><dd>The action was successfully received, understood, and accepted</dd>
<dt>3xx: Redirection</dt><dd>Further action must be taken in order to complete the request</dd>
<dt>4xx: Client Error</dt><dd>The request contains bad syntax or cannot be fulfilled</dd>
<dt>5xx: Server Error</dt><dd>The server failed to fulfill an apparently valid request</dd></dl>


<h2>HTTP Status Codes</h2>
<p>From <code>http_protocol.c</code> and <code>httpd.h</code> - <code>RESPONSE_CODES 83</code></p>
<p>These are the <dfn title="100 101 102 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 300 301 302 303 304 305 306 307 308 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 500 501 502 503 504 505 506 507 508 509 510 511">codes</dfn> in a shell-script friendly fashion.</p>

<h3>1xx Info / Informational</h3><ul>
<li>100 Continue</li>
<li>101 Switching Protocols</li>
<li>102 Processing</li>
</ul>

<h3>2xx Success / OK</h3><ul>
<li>200 OK</li>
<li>201 Created</li>
<li>202 Accepted</li>
<li>203 Non-Authoritative Information</li>
<li>204 No Content</li>
<li>205 Reset Content</li>
<li>206 Partial Content</li>
<li>207 Multi-Status</li>
<li>208 Already Reported</li>
<li>226 IM Used</li>
</ul>

<h3>3xx Redirect</h3><ul>
<li>300 Multiple Choices</li>
<li>301 Moved Permanently</li>
<li>302 Found</li>
<li>303 See Other</li>
<li>304 Not Modified</li>
<li>305 Use Proxy</li>
<li>307 Temporary Redirect</li>
<li>308 Permanent Redirect</li>
</ul>

<h3>4xx Client Error</h3><ul>
<li>400 Bad Request</li>
<li>401 Unauthorized</li>
<li>402 Payment Required</li>
<li>403 Forbidden</li>
<li>404 Not Found</li>
<li>405 Method Not Allowed</li>
<li>406 Not Acceptable</li>
<li>407 Proxy Authentication Required</li>
<li>408 Request Timeout</li>
<li>409 Conflict</li>
<li>410 Gone</li>
<li>411 Length Required</li>
<li>412 Precondition Failed</li>
<li>413 Request Entity Too Large</li>
<li>414 Request-URI Too Long</li>
<li>415 Unsupported Media Type</li>
<li>416 Requested Range Not Satisfiable</li>
<li>417 Expectation Failed</li>
<li>422 Unprocessable Entity</li>
<li>423 Locked</li>
<li>424 Failed Dependency</li>
<li>426 Upgrade Required</li>
<li>428 Precondition Required</li>
<li>429 Too Many Requests</li>
<li>431 Request Header Fields Too Large</li>
</ul>

<h3>5xx Server Error</h3><ul>
<li>500 Internal Server Error</li>
<li>501 Not Implemented</li>
<li>502 Bad Gateway</li>
<li>503 Service Unavailable</li>
<li>504 Gateway Timeout</li>
<li>505 HTTP Version Not Supported</li>
<li>506 Variant Also Negotiates</li>
<li>507 Insufficient Storage</li>
<li>508 Loop Detected</li>
<li>510 Not Extended</li>
<li>511 Network Authentication Required</li>
</ul>


<h2>HTTP Header Viewer</h2>
<p>Want to check the HTTP Headers?  Use my <a href="http://www.askapache.com/online-tools/http-headers-tool/">Header Viewer</a>.  I recently added Hexdumps.</p>
<p><a href="http://www.askapache.com/online-tools/http-headers-tool/"><img src="http://uploads.askapache.com/2013/04/http-status-codes-tool.png" alt="HTTP Status Codes" width="543" height="330" title="http status codes tool" /></a></p>


<h2>Full Headers and Content</h2>
<p>I wrote a simple script to trigger all 83 Response Codes, using the super cool <a href="http://www.askapache.com/php/php-errordocument.html">Htaccess Redirect/ErrorDocument trick</a>, and saved the headers and body from each for your viewing pleasure.  This is from Apache 2.4.4 for the <dfn title="100, 101, 102, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 300, 301, 302, 303, 304, 305, 306, 307, 308, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511">83 Status Codes</dfn>.</p>

<p>Example: My 503 Error Page</p>
<p><img src="http://uploads.askapache.com/2013/04/HTTP-Status-Codes.png" alt="HTTP Status Codes" width="446" height="261" title="HTTP Status Codes" /></p>


<h3>1xx Info / Informational</h3>

<h4>100 Continue</h4>
<pre>HTTP/1.1 100 Continue
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 502
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;100 Continue&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Continue&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>101 Switching Protocols</h4>
<pre>HTTP/1.1 101 Switching Protocols
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 524
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;101 Switching Protocols&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Switching Protocols&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>102 Processing</h4>
<pre>HTTP/1.1 102 Processing
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 506
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;102 Processing&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Processing&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>

<h3>2xx Success / OK</h3>
<h4>200 OK</h4>
<pre>HTTP/1.1 200 OK
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 490
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;200 OK&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;OK&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>201 Created</h4>
<pre>HTTP/1.1 201 Created
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 500
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;201 Created&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Created&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>202 Accepted</h4>
<pre>HTTP/1.1 202 Accepted
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 502
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;202 Accepted&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Accepted&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>203 Non-Authoritative Information</h4>
<pre>HTTP/1.1 203 Non-Authoritative Information
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 544
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;203 Non-Authoritative Information&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Non-Authoritative Information&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>204 No Content</h4>
<pre>HTTP/1.1 204 No Content
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 0
&nbsp;
</pre>
<h4>205 Reset Content</h4>
<pre>HTTP/1.1 205 Reset Content
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 512
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;205 Reset Content&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Reset Content&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>206 Partial Content</h4>
<pre>HTTP/1.1 206 Partial Content
Date: Sat, 06 Apr 2013 21:10:39 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 516
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;206 Partial Content&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Partial Content&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>207 Multi-Status</h4>
<pre>HTTP/1.1 207 Multi-Status
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 510
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;207 Multi-Status&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Multi-Status&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>208 Already Reported</h4>
<pre>HTTP/1.1 208 Already Reported
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 518
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;208 Already Reported&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Already Reported&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>226 IM Used</h4>
<pre>HTTP/1.1 226 IM Used
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 500
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;226 IM Used&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;IM Used&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>

<h3>3xx Redirect</h3>
<table summary="3xx status codes" class="nice-table" caption="3xx HTTP status codes">
<tbody><tr><th scope="col">Code</th><th scope="col">Description</th></tr>
<tr><td>300 (Multiple choices)</td><td>The server has several actions available based on the request. The server may choose an action based on the requestor (user agent) or the server may present a list so the requestor can choose an action.</td></tr>
<tr><td>301 Moved Permanently</td><td>This and all future requests should be directed to the given URI.</td></tr>
<tr><td>302 (Moved temporarily)</td><td>The server is currently responding to the request with a page from a different location, but the requestor should continue to use the original location for future requests. This code is similar to a 301 in that for a GET or HEAD request, it automatically forwards the requestor to a different location, but you shouldn't use it to tell the Googlebot that a page or site has moved because Googlebot will continue to crawl and index the original location.</td></tr>
<tr><td>303 See Other (since HTTP/1.1)</td><td>The response to the request can be found under another URI using a GET method. When received in response to a POST (or PUT/DELETE), it should be assumed that the server has received the data and the redirect should be issued with a separate GET message.</td></tr>
<tr><td>304 (Not modified)</td><td><p>The requested page hasn't been modified since the last request. When the server returns this response, it doesn't return the contents of the page.</p>
<p>You should configure your server to return this response (called the If-Modified-Since HTTP header) when a page hasn't changed since the last time the requestor asked for it. This saves you bandwidth and overhead because your server can tell Googlebot that a page hasn't changed since the last time it was crawled.</p></td></tr>
<tr><td>305 Use Proxy (since HTTP/1.1)</td><td>The requested resource is only available through a proxy, whose address is provided in the response. Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.</td></tr>
<tr><td>306 Switch Proxy</td><td>No longer used. Originally meant "Subsequent requests should use the specified proxy."</td></tr>
<tr><td>307 (Temporary redirect)</td><td>The server is currently responding to the request with a page from a different location, but the requestor should continue to use the original location for future requests. This code is similar to a 301 in that for a GET or HEAD request, it automatically forwards the requestor to a different location, but you shouldn't use it to tell the Googlebot that a page or site has moved because Googlebot will continue to crawl and index the original location.</td></tr>
<tr><td>308 (Permanent redirect)</td><td>The target resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs.  Clients with link editing capabilities ought to automatically re-link references to the effective request URI to one or more of the new references returned by the server, where possible.  Caches MAY use a heuristic to determine freshness for 308 responses.  The new permanent URI SHOULD be given by the Location field in the response.  A response payload can contain a short hypertext note with a hyperlink to the new URI(s). <strong>Note:</strong> <em>This status code is similar to 301 Moved Permanently, except that it does not allow rewriting the request method from POST to GET.</em></td></tr></tbody></table>
<pre>+---------------------------------------------------------------+-----------+-----------+
|                                                               | Permanent | Temporary |
+---------------------------------------------------------------+-----------+-----------+
| Allows changing the request method from POST to GET           | 301       | 302       |
|                                                               |           |           |
| Does not allow changing the request method from POST to GET   | 308       | 307       |
+---------------------------------------------------------------+-----------+-----------+</pre>





<h3>4xx Client Error</h3>
<h4>400 Bad Request</h4>
<pre>HTTP/1.1 400 Bad Request
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;400 Bad Request&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Bad Request&lt;/h1&gt;
&lt;p&gt;Your browser sent a request that this server could not understand.&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>401 Unauthorized</h4>
<pre>HTTP/1.1 401 Unauthorized
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 381
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;401 Unauthorized&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Unauthorized&lt;/h1&gt;
&lt;p&gt;This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn&#039;t understand how to supply
the credentials required.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>402 Payment Required</h4>
<pre>HTTP/1.1 402 Payment Required
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 518
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;402 Payment Required&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Payment Required&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>403 Forbidden</h4>
<pre>HTTP/1.1 403 Forbidden
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 207
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;403 Forbidden&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Forbidden&lt;/h1&gt;
&lt;p&gt;You don&#039;t have permission to access /e/403
on this server.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>404 Not Found</h4>
<pre>HTTP/1.1 404 Not Found
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 203
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;404 Not Found&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Not Found&lt;/h1&gt;
&lt;p&gt;The requested URL /e/404 was not found on this server.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>405 Method Not Allowed</h4>
<pre>HTTP/1.1 405 Method Not Allowed
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Allow: TRACE
Content-Length: 226
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;405 Method Not Allowed&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Method Not Allowed&lt;/h1&gt;
&lt;p&gt;The requested method GET is not allowed for the URL /e/405.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>406 Not Acceptable</h4>
<pre>HTTP/1.1 406 Not Acceptable
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 256
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;406 Not Acceptable&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Not Acceptable&lt;/h1&gt;
&lt;p&gt;An appropriate representation of the requested resource /e/406 could not be found on this server.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>407 Proxy Authentication Required</h4>
<pre>HTTP/1.1 407 Proxy Authentication Required
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 415
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;407 Proxy Authentication Required&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Proxy Authentication Required&lt;/h1&gt;
&lt;p&gt;This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn&#039;t understand how to supply
the credentials required.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>408 Request Timeout</h4>
<pre>HTTP/1.1 408 Request Timeout
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 221
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;408 Request Timeout&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Request Timeout&lt;/h1&gt;
&lt;p&gt;Server timeout waiting for the HTTP request from the client.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>409 Conflict</h4>
<pre>HTTP/1.1 409 Conflict
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 502
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;409 Conflict&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Conflict&lt;/h1&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>410 Gone</h4>
<pre>HTTP/1.1 410 Gone
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 300
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;410 Gone&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Gone&lt;/h1&gt;
&lt;p&gt;The requested resource&lt;br /&gt;/e/410&lt;br /&gt;
is no longer available on this server and there is no forwarding address.
Please remove all references to this resource.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>411 Length Required</h4>
<pre>HTTP/1.1 411 Length Required
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 238
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;411 Length Required&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Length Required&lt;/h1&gt;
&lt;p&gt;A request of the requested method GET requires a valid Content-length.&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>412 Precondition Failed</h4>
<pre>HTTP/1.1 412 Precondition Failed
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 239
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;412 Precondition Failed&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Precondition Failed&lt;/h1&gt;
&lt;p&gt;The precondition on the request for the URL /e/412 evaluated to false.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>413 Request Entity Too Large</h4>
<pre>HTTP/1.1 413 Request Entity Too Large
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 333
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;413 Request Entity Too Large&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Request Entity Too Large&lt;/h1&gt;
The requested resource&lt;br /&gt;/e/413&lt;br /&gt;
does not allow request data with GET requests, or the amount of data provided in
the request exceeds the capacity limit.
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>414 Request-URI Too Long</h4>
<pre>HTTP/1.1 414 Request-URI Too Long
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 248
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;414 Request-URI Too Long&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Request-URI Too Long&lt;/h1&gt;
&lt;p&gt;The requested URL&#039;s length exceeds the capacity
limit for this server.&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>415 Unsupported Media Type</h4>
<pre>HTTP/1.1 415 Unsupported Media Type
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 263
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;415 Unsupported Media Type&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Unsupported Media Type&lt;/h1&gt;
&lt;p&gt;The supplied request data is not in a format
acceptable for processing by this resource.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>416 Requested Range Not Satisfiable</h4>
<pre>HTTP/1.1 416 Requested Range Not Satisfiable
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 314
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;416 Requested Range Not Satisfiable&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Requested Range Not Satisfiable&lt;/h1&gt;
&lt;p&gt;None of the range-specifier values in the Range
request-header field overlap the current extent
of the selected resource.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>417 Expectation Failed</h4>
<pre>HTTP/1.1 417 Expectation Failed
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 312
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;417 Expectation Failed&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Expectation Failed&lt;/h1&gt;
&lt;p&gt;No expectation was seen, the Expect request-header 
field was not presented by the client.
&lt;/p&gt;&lt;p&gt;Only the 100-continue expectation is supported.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>422 Unprocessable Entity</h4>
<pre>HTTP/1.1 422 Unprocessable Entity
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 285
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;422 Unprocessable Entity&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Unprocessable Entity&lt;/h1&gt;
&lt;p&gt;The server understands the media type of the
request entity, but was unable to process the
contained instructions.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>423 Locked</h4>
<pre>HTTP/1.1 423 Locked
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 277
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;423 Locked&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Locked&lt;/h1&gt;
&lt;p&gt;The requested resource is currently locked.
The lock must be released or proper identification
given before the method can be applied.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>424 Failed Dependency</h4>
<pre>HTTP/1.1 424 Failed Dependency
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 300
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;424 Failed Dependency&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Failed Dependency&lt;/h1&gt;
&lt;p&gt;The method could not be performed on the resource
because the requested action depended on another
action and that other action failed.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>



<h4>426 Upgrade Required</h4>
<pre>HTTP/1.1 426 Upgrade Required
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 385
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;426 Upgrade Required&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Upgrade Required&lt;/h1&gt;
&lt;p&gt;The requested resource can only be retrieved
using SSL.  The server is willing to upgrade the current
connection to SSL, but your client doesn&#039;t support it.
Either upgrade your client, or try requesting the page
using https://
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>428 Precondition Required</h4>
<pre>HTTP/1.1 428 Precondition Required
Date: Sat, 06 Apr 2013 21:10:40 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 215
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;428 Precondition Required&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Precondition Required&lt;/h1&gt;
&lt;p&gt;The request is required to be conditional.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>429 Too Many Requests</h4>
<pre>HTTP/1.1 429 Too Many Requests
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 227
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;429 Too Many Requests&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Too Many Requests&lt;/h1&gt;
&lt;p&gt;The user has sent too many requests
in a given amount of time.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>

<h4>431 Request Header Fields Too Large</h4>
<pre>HTTP/1.1 431 Request Header Fields Too Large
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 273
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;431 Request Header Fields Too Large&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Request Header Fields Too Large&lt;/h1&gt;
&lt;p&gt;The server refused this request because
the request header fields are too large.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>



<h3>5xx Server Error</h3>

<h4>500 Internal Server Error</h4>
<pre>HTTP/1.1 500 Internal Server Error
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 528
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;500 Internal Server Error&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Internal Server Error&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or
misconfiguration and was unable to complete
your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator at 
 you@example.com to inform them of the time this error occurred,
 and the actions you performed just before this error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available
in the server error log.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>501 Not Implemented</h4>
<pre>HTTP/1.1 501 Not Implemented
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Allow: TRACE
Content-Length: 196
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;501 Not Implemented&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Not Implemented&lt;/h1&gt;
&lt;p&gt;GET to /e/501 not supported.&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>502 Bad Gateway</h4>
<pre>HTTP/1.1 502 Bad Gateway
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 232
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;502 Bad Gateway&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Bad Gateway&lt;/h1&gt;
&lt;p&gt;The proxy server received an invalid
response from an upstream server.&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>503 Service Unavailable</h4>
<pre>HTTP/1.1 503 Service Unavailable
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 299
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;503 Service Unavailable&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Service Unavailable&lt;/h1&gt;
&lt;p&gt;The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>504 Gateway Timeout</h4>
<pre>HTTP/1.1 504 Gateway Timeout
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 247
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;504 Gateway Timeout&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Gateway Timeout&lt;/h1&gt;
&lt;p&gt;The gateway did not receive a timely response
from the upstream server or application.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>505 HTTP Version Not Supported</h4>
<pre>HTTP/1.1 505 HTTP Version Not Supported
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 538
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;505 HTTP Version Not Supported&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;HTTP Version Not Supported&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or
misconfiguration and was unable to complete
your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator at 
 you@example.com to inform them of the time this error occurred,
 and the actions you performed just before this error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available
in the server error log.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>506 Variant Also Negotiates</h4>
<pre>HTTP/1.1 506 Variant Also Negotiates
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 304
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;506 Variant Also Negotiates&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Variant Also Negotiates&lt;/h1&gt;
&lt;p&gt;A variant for the requested resource
&lt;pre&gt;
/e/506
&lt;/pre&gt;
is itself a negotiable resource. This indicates a configuration error.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>507 Insufficient Storage</h4>
<pre>HTTP/1.1 507 Insufficient Storage
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 389
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;507 Insufficient Storage&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Insufficient Storage&lt;/h1&gt;
&lt;p&gt;The method could not be performed on the resource
because the server is unable to store the
representation needed to successfully complete the
request.  There is insufficient free space left in
your storage allocation.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>508 Loop Detected</h4>
<pre>HTTP/1.1 508 Loop Detected
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 232
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;508 Loop Detected&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Loop Detected&lt;/h1&gt;
&lt;p&gt;The server terminated an operation because
it encountered an infinite loop.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>

<h4>510 Not Extended</h4>
<pre>HTTP/1.1 510 Not Extended
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 247
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;510 Not Extended&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Not Extended&lt;/h1&gt;
&lt;p&gt;A mandatory extension policy in the request is not
accepted by the server for this resource.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>


<h4>511 Network Authentication Required</h4>
<pre>HTTP/1.1 511 Network Authentication Required
Date: Sat, 06 Apr 2013 21:10:41 GMT
Server: Apache/2.4.4 (Unix)
Content-Length: 249
Content-Type: text/html; charset=iso-8859-1
&nbsp;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;511 Network Authentication Required&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Network Authentication Required&lt;/h1&gt;
&lt;p&gt;The client needs to authenticate to gain
network access.&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</pre>

<h3>Total Unsupported Errors</h3>
<p><strong>Success Codes</strong>: <em style="font-size:smaller">209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225</em> are all currently unsupported.</p>
<p><strong>Redirect Codes</strong>: <em style="font-size:smaller">300, 301, 302, 303, 304, 305, 306, 307, 308</em>, all returned the correct ErrorDocument but due to the updates to Apache they then continue through and return the redirect url (issuing 404) instead of the actual 3xx (codes).  Now they correctly redirect basically, whereas in earlier versions you could trick Apache into sending the Headers and ErrorDocument specific to the 3xx. No biggie, everyone knows the 3xx.</p>
<p><strong>Client Error Codes</strong>: <em style="font-size:smaller">418, 419, 420, 421, 425, 427, 430</em> currently unsupported.</p>
<p><strong>Server Error Code</strong>: <em style="font-size:smaller">509</em> currently unsupported.</p>


<h2>Creating ErrorDocument Output</h2>

<h3>Htaccess Used for Triggers</h3>
<p>Basically just save this as your .htaccess file.  Then when you request, <code>/e/503</code>, it will trigger a 503 response.  Took me a long time to come up with this trick btw..  More info about this <a href="http://www.askapache.com/php/php-errordocument.html">ErrorDocument triggering</a> trick.</p>
<p>Then I compiled the latest 2.4.4 Apache HTTPD from source and set it up on a staging server in order to get the newest Apache responses.  The 2.2 Apaches and below had 57 codes vs 2.4.4 has 83.</p>
<pre>
ErrorDocument 100 default
ErrorDocument 101 default
errorDocument 102 default
ErrorDocument 200 default
ErrorDocument 201 default
ErrorDocument 202 default
ErrorDocument 203 default
ErrorDocument 204 default
ErrorDocument 205 default
ErrorDocument 206 default
ErrorDocument 207 default
ErrorDocument 208 default
ErrorDocument 400 default
ErrorDocument 401 default
ErrorDocument 402 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 407 default
ErrorDocument 408 default
ErrorDocument 409 default
ErrorDocument 410 default
ErrorDocument 411 default
ErrorDocument 412 default
ErrorDocument 413 default
ErrorDocument 414 default
ErrorDocument 415 default
ErrorDocument 416 default
ErrorDocument 417 default
&nbsp;
Redirect 100 /e/100
Redirect 101 /e/101
Redirect 102 /e/102
Redirect 200 /e/200
Redirect 201 /e/201
Redirect 202 /e/202
Redirect 203 /e/203
Redirect 204 /e/204
Redirect 205 /e/205
Redirect 206 /e/206
Redirect 207 /e/207
Redirect 208 /e/208
Redirect 209 /e/209
Redirect 210 /e/210
Redirect 211 /e/211
Redirect 212 /e/212
Redirect 213 /e/213
Redirect 214 /e/214
Redirect 215 /e/215
Redirect 216 /e/216
Redirect 217 /e/217
Redirect 218 /e/218
Redirect 219 /e/219
Redirect 220 /e/220
Redirect 221 /e/221
Redirect 222 /e/222
Redirect 223 /e/223
Redirect 224 /e/224
Redirect 225 /e/225
Redirect 226 /e/226
Redirect 400 /e/400
Redirect 401 /e/401
Redirect 402 /e/402
Redirect 403 /e/403
Redirect 404 /e/404
Redirect 405 /e/405
Redirect 406 /e/406
Redirect 407 /e/407
Redirect 408 /e/408
Redirect 409 /e/409
Redirect 410 /e/410
Redirect 411 /e/411
Redirect 412 /e/412
Redirect 413 /e/413
Redirect 414 /e/414
Redirect 415 /e/415
Redirect 416 /e/416
Redirect 417 /e/417
Redirect 418 /e/418
Redirect 419 /e/419
Redirect 420 /e/420
Redirect 421 /e/421
Redirect 422 /e/422
Redirect 423 /e/423
Redirect 424 /e/424
Redirect 425 /e/425
Redirect 426 /e/426
Redirect 427 /e/427
Redirect 428 /e/428
Redirect 429 /e/429
Redirect 430 /e/430
Redirect 431 /e/431
Redirect 500 /e/500
Redirect 501 /e/501
Redirect 502 /e/502
Redirect 503 /e/503
Redirect 504 /e/504
Redirect 505 /e/505
Redirect 506 /e/506
Redirect 507 /e/507
Redirect 508 /e/508
Redirect 509 /e/509
Redirect 510 /e/510
Redirect 511 /e/511</pre>

<h3>cURL Script for Headers and Output</h3>
<p>Just a simple shell script you can run from Bash after setting up the Htaccess Triggering.  This just loops through all 83 Codes and requests the special uri that causes Apache to respond with the HTTP Status Code and Relevant ErrorDocument.</p>
<pre>
for c in 100 101 102 \
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 \
300 301 302 303 304 305 306 307 308 \
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 \
500 501 502 503 504 505 506 507 508 509 510 511;
do
   curl -L4siv -o - --connect-timeout 1 --max-time 1 --retry 0 --max-redirs 3 -A &#039;AskApache&#039; -e &#039;localhost&#039; --resolve a.com:80:127.0.0.1 http://a.com/e/${c} 2&gt;&amp;1;
done;
</pre>




<h2>Extra Info</h2>

<h3>Apache Internal Status Code Names</h3>
<p>The rest of the 83 Codes are NULL for future use.</p>
<ul>
<li>100 = <var>HTTP_CONTINUE</var></li>
<li>101 = <var>HTTP_SWITCHING_PROTOCOLS</var></li>
<li>102 = <var>HTTP_PROCESSING</var></li>
<li>200 = <var>HTTP_OK</var></li>
<li>201 = <var>HTTP_CREATED</var></li>
<li>202 = <var>HTTP_ACCEPTED</var></li>
<li>203 = <var>HTTP_NON_AUTHORITATIVE</var></li>
<li>204 = <var>HTTP_NO_CONTENT</var></li>
<li>205 = <var>HTTP_RESET_CONTENT</var></li>
<li>206 = <var>HTTP_PARTIAL_CONTENT</var></li>
<li>207 = <var>HTTP_MULTI_STATUS</var></li>
<li>208 = <var>HTTP_ALREADY_REPORTED</var></li>
<li>226 = <var>HTTP_IM_USED</var></li>
<li>300 = <var>HTTP_MULTIPLE_CHOICES</var></li>
<li>301 = <var>HTTP_MOVED_PERMANENTLY</var></li>
<li>302 = <var>HTTP_MOVED_TEMPORARILY</var></li>
<li>303 = <var>HTTP_SEE_OTHER</var></li>
<li>304 = <var>HTTP_NOT_MODIFIED</var></li>
<li>305 = <var>HTTP_USE_PROXY</var></li>
<li>307 = <var>HTTP_TEMPORARY_REDIRECT</var></li>
<li>308 = <var>HTTP_PERMANENT_REDIRECT</var></li>
<li>400 = <var>HTTP_BAD_REQUEST</var></li>
<li>401 = <var>HTTP_UNAUTHORIZED</var></li>
<li>402 = <var>HTTP_PAYMENT_REQUIRED</var></li>
<li>403 = <var>HTTP_FORBIDDEN</var></li>
<li>404 = <var>HTTP_NOT_FOUND</var></li>
<li>405 = <var>HTTP_METHOD_NOT_ALLOWED</var></li>
<li>406 = <var>HTTP_NOT_ACCEPTABLE</var></li>
<li>407 = <var>HTTP_PROXY_AUTHENTICATION_REQUIRED</var></li>
<li>408 = <var>HTTP_REQUEST_TIME_OUT</var></li>
<li>409 = <var>HTTP_CONFLICT</var></li>
<li>410 = <var>HTTP_GONE</var></li>
<li>411 = <var>HTTP_LENGTH_REQUIRED</var></li>
<li>412 = <var>HTTP_PRECONDITION_FAILED</var></li>
<li>413 = <var>HTTP_REQUEST_ENTITY_TOO_LARGE</var></li>
<li>414 = <var>HTTP_REQUEST_URI_TOO_LARGE</var></li>
<li>415 = <var>HTTP_UNSUPPORTED_MEDIA_TYPE</var></li>
<li>416 = <var>HTTP_RANGE_NOT_SATISFIABLE</var></li>
<li>417 = <var>HTTP_EXPECTATION_FAILED</var></li>
<li>422 = <var>HTTP_UNPROCESSABLE_ENTITY</var></li>
<li>423 = <var>HTTP_LOCKED</var></li>
<li>424 = <var>HTTP_FAILED_DEPENDENCY</var></li>
<li>426 = <var>HTTP_UPGRADE_REQUIRED</var></li>
<li>428 = <var>HTTP_PRECONDITION_REQUIRED</var></li>
<li>429 = <var>HTTP_TOO_MANY_REQUESTS</var></li>
<li>431 = <var>HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE</var></li>
<li>500 = <var>HTTP_INTERNAL_SERVER_ERROR</var></li>
<li>501 = <var>HTTP_NOT_IMPLEMENTED</var></li>
<li>502 = <var>HTTP_BAD_GATEWAY</var></li>
<li>503 = <var>HTTP_SERVICE_UNAVAILABLE</var></li>
<li>504 = <var>HTTP_GATEWAY_TIME_OUT</var></li>
<li>505 = <var>HTTP_VERSION_NOT_SUPPORTED</var></li>
<li>506 = <var>HTTP_VARIANT_ALSO_VARIES</var></li>
<li>507 = <var>HTTP_INSUFFICIENT_STORAGE</var></li>
<li>508 = <var>HTTP_LOOP_DETECTED</var></li>
<li>510 = <var>HTTP_NOT_EXTENDED</var></li>
<li>511 = <var>HTTP_NETWORK_AUTHENTICATION_REQUIRED</var></li>
</ul>


<h3>3xx Browser Support / Live Tests</h3>
<p><a href="http://www.askapache.com/cgi-bin/asis/3xx/">Test 3xx Redirection Capabilities</a> of your browser.  Thanks to <a href="http://greenbytes.de/">green bytes</a>!</p>
<table><thead><tr><th colspan="2">Test Case</th><th>Firefox 18</th><th>Microsoft IE 9</th><th>Microsoft IE 10 (Consumer Preview)</th><th>Opera 12</th><th>Safari 5.1</th>
<th>Google Chrome 22</th><th>Konqueror 4.7.2</th></tr></thead><tbody>
<tr><th colspan="2">Summary</th>
<td style="text-align: center;"><img alt="100% passes, 0% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A55%2C0%2C0%2C0%2C0&amp;chs=128x128" title="100% passes, 0% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 100</small></td>
<td style="text-align: center;"><img alt="89% passes, 11% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A49%2C6%2C0%2C0%2C0&amp;chs=128x128" title="89% passes, 11% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 89</small></td>
<td style="text-align: center;"><img alt="91% passes, 9% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A50%2C5%2C0%2C0%2C0&amp;chs=128x128" title="91% passes, 9% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 91</small></td>
<td style="text-align: center;"><img alt="85% passes, 15% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A47%2C8%2C0%2C0%2C0&amp;chs=128x128" title="85% passes, 15% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 85</small></td>
<td style="text-align: center;"><img alt="89% passes, 11% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A49%2C6%2C0%2C0%2C0&amp;chs=128x128" title="89% passes, 11% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 89</small></td>
<td style="text-align: center;"><img alt="100% passes, 0% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A55%2C0%2C0%2C0%2C0&amp;chs=128x128" title="100% passes, 0% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 100</small></td>
<td style="text-align: center;"><img alt="64% passes, 36% failures, 0% warnings, 0% unsupported, 0% to-do" src="http://chart.apis.google.com/chart?cht=p&amp;chco=d0ffd0%2Cffd0d0%2Cffff80%2Ce0e0e0%2Cffffff&amp;chd=t%3A35%2C20%2C0%2C0%2C0&amp;chs=128x128" title="64% passes, 36% failures, 0% warnings, 0% unsupported, 0% to do" /><br /><small> Score: 64</small></td>
</tr></tbody>
</table>


<h3>Connection Dropped</h3>
<p>Apache drops the connection for these codes.</p>
<ul><li>400 BAD_REQUEST</li><li>408 REQUEST_TIME_OUT</li><li>411 LENGTH_REQUIRED</li><li>413 REQUEST_ENTITY_TOO_LARGE</li><li>414 REQUEST_URI_TOO_LARGE</li><li>500 INTERNAL_SERVER_ERROR</li><li>503 SERVICE_UNAVAILABLE</li><li>501 NOT_IMPLEMENTED</li></ul>

<h3>Status Codes in C</h3>
<p>Probably my all time favorite, from <a href="http://uploads.askapache.com/2013/04/packet-http.c">Wireshark</a>.</p>
<pre>
static const value_string vals_status_code[] = {
  { 100, "Continue" },
  { 101, "Switching Protocols" },
  { 102, "Processing" },
  { 199, "Informational - Others" },
&nbsp;
  { 200, "OK"},
  { 201, "Created"},
  { 202, "Accepted"},
  { 203, "Non-authoritative Information"},
  { 204, "No Content"},
  { 205, "Reset Content"},
  { 206, "Partial Content"},
  { 207, "Multi-Status"},
  { 299, "Success - Others"},
&nbsp;
  { 300, "Multiple Choices"},
  { 301, "Moved Permanently"},
  { 302, "Found"},
  { 303, "See Other"},
  { 304, "Not Modified"},
  { 305, "Use Proxy"},
  { 307, "Temporary Redirect"},
  { 399, "Redirection - Others"},
&nbsp;
  { 400, "Bad Request"},
  { 401, "Unauthorized"},
  { 402, "Payment Required"},
  { 403, "Forbidden"},
  { 404, "Not Found"},
  { 405, "Method Not Allowed"},
  { 406, "Not Acceptable"},
  { 407, "Proxy Authentication Required"},
  { 408, "Request Time-out"},
  { 409, "Conflict"},
  { 410, "Gone"},
  { 411, "Length Required"},
  { 412, "Precondition Failed"},
  { 413, "Request Entity Too Large"},
  { 414, "Request-URI Too Long"},
  { 415, "Unsupported Media Type"},
  { 416, "Requested Range Not Satisfiable"},
  { 417, "Expectation Failed"},
  { 418, "I&#039;m a teapot"},    /* RFC 2324 */
  { 422, "Unprocessable Entity"},
  { 423, "Locked"},
  { 424, "Failed Dependency"},
  { 499, "Client Error - Others"},
&nbsp;
  { 500, "Internal Server Error"},
  { 501, "Not Implemented"},
  { 502, "Bad Gateway"},
  { 503, "Service Unavailable"},
  { 504, "Gateway Time-out"},
  { 505, "HTTP Version not supported"},
  { 507, "Insufficient Storage"},
  { 599, "Server Error - Others"},
&nbsp;
  { 0,   NULL}
};</pre>

<h3>PHP of Updated Codes</h3>
<p>This type of table is used by software like WordPress, <a href="https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Response.php#L471">Zend</a>, Snoopy, Curl, you name it.  Always good to update.</p>
<pre>
array(
  // INFORMATIONAL CODES
  100 =&gt; &#039;Continue&#039;,
  101 =&gt; &#039;Switching Protocols&#039;,
  102 =&gt; &#039;Processing&#039;,
  
  // SUCCESS CODES
  200 =&gt; &#039;OK&#039;,
  201 =&gt; &#039;Created&#039;,
  202 =&gt; &#039;Accepted&#039;,
  203 =&gt; &#039;Non-Authoritative Information&#039;,
  204 =&gt; &#039;No Content&#039;,
  205 =&gt; &#039;Reset Content&#039;,
  206 =&gt; &#039;Partial Content&#039;,
  207 =&gt; &#039;Multi-status&#039;,
  208 =&gt; &#039;Already Reported&#039;,
  
  // REDIRECTION CODES
  300 =&gt; &#039;Multiple Choices&#039;,
  301 =&gt; &#039;Moved Permanently&#039;,
  302 =&gt; &#039;Found&#039;,
  303 =&gt; &#039;See Other&#039;,
  304 =&gt; &#039;Not Modified&#039;,
  305 =&gt; &#039;Use Proxy&#039;,
  306 =&gt; &#039;Switch Proxy&#039;, // Deprecated
  307 =&gt; &#039;Temporary Redirect&#039;,
  
  // CLIENT ERROR
  400 =&gt; &#039;Bad Request&#039;,
  401 =&gt; &#039;Unauthorized&#039;,
  402 =&gt; &#039;Payment Required&#039;,
  403 =&gt; &#039;Forbidden&#039;,
  404 =&gt; &#039;Not Found&#039;,
  405 =&gt; &#039;Method Not Allowed&#039;,
  406 =&gt; &#039;Not Acceptable&#039;,
  407 =&gt; &#039;Proxy Authentication Required&#039;,
  408 =&gt; &#039;Request Time-out&#039;,
  409 =&gt; &#039;Conflict&#039;,
  410 =&gt; &#039;Gone&#039;,
  411 =&gt; &#039;Length Required&#039;,
  412 =&gt; &#039;Precondition Failed&#039;,
  413 =&gt; &#039;Request Entity Too Large&#039;,
  414 =&gt; &#039;Request-URI Too Large&#039;,
  415 =&gt; &#039;Unsupported Media Type&#039;,
  416 =&gt; &#039;Requested range not satisfiable&#039;,
  417 =&gt; &#039;Expectation Failed&#039;,
  418 =&gt; &#039;I\&#039;m a teapot&#039;,
  422 =&gt; &#039;Unprocessable Entity&#039;,
  423 =&gt; &#039;Locked&#039;,
  424 =&gt; &#039;Failed Dependency&#039;,
  425 =&gt; &#039;Unordered Collection&#039;,
  426 =&gt; &#039;Upgrade Required&#039;,
  428 =&gt; &#039;Precondition Required&#039;,
  429 =&gt; &#039;Too Many Requests&#039;,
  431 =&gt; &#039;Request Header Fields Too Large&#039;,
  
  // SERVER ERROR
  500 =&gt; &#039;Internal Server Error&#039;,
  501 =&gt; &#039;Not Implemented&#039;,
  502 =&gt; &#039;Bad Gateway&#039;,
  503 =&gt; &#039;Service Unavailable&#039;,
  504 =&gt; &#039;Gateway Time-out&#039;,
  505 =&gt; &#039;HTTP Version not supported&#039;,
  506 =&gt; &#039;Variant Also Negotiates&#039;,
  507 =&gt; &#039;Insufficient Storage&#039;,
  508 =&gt; &#039;Loop Detected&#039;,
  511 =&gt; &#039;Network Authentication Required&#039;
);
</pre>

<h3>Related RFC Reads</h3>
<ul>
<li><a href="http://tools.ietf.org/html/rfc6585" title="[RFC6585]">RFC 6585</a> - Additional HTTP Status Codes, 2012</li>
<li><a href="http://rfc.askapache.com/rfc2295" title="[RFC2295]">RFC 2295</a> - Transparent Content Negotiation in HTTP, March 1998.</li>
<li><a href="http://rfc.askapache.com/rfc2518" title="[RFC2518]">RFC 2518</a> - HTTP Extensions for Distributed Authoring -- WEBDAV, February 1999.</li>
<li><a href="http://tools.ietf.org/html/rfc2616" title="[RFC2616]">RFC 2616</a> - Hypertext Transfer Protocol -- HTTP/1.1, June 1999.</li>
<li><a href="http://rfc.askapache.com/rfc2774" title="[RFC2774]">RFC 2774</a> - An HTTP Extension Framework, February 2000.</li>
<li><a href="http://rfc.askapache.com/rfc2817" title="[RFC2817]">RFC 2817</a> - Upgrading to TLS Within HTTP/1.1, May 2000.</li>
<li><a href="http://tools.ietf.org/html/rfc3229" title="[RFC3229]">RFC 3229</a> - Delta encoding in HTTP, January 2002.</li>
<li><a href="http://tools.ietf.org/html/rfc4918" title="[RFC4918]">RFC 4918</a> - HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV), June 2007.</li>
<li><a href="http://tools.ietf.org/html/draft-reschke-http-status-308-07">HTTP Status Code 308</a></li>
</ul>



<h3>More Reading</h3>
<ul>
<li>Awesome: <a href="http://greenbytes.de/tech/tc/httpredirects/">Test Cases for HTTP Redirects</a></li>
<li><a href="http://greenbytes.de/tech/tc/httpredirects/">Test Cases for HTTP Redirects</a></li>
<li>Official W3.org <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP/1.1: Status Code Definitions</a></li>
<li>Google Webmaster Tools Help - <a href="http://support.google.com/webmasters/bin/answer.py?hl=en&answer=40132">HTTP status codes</a></li>
<li>Wikipedia - <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes">List of HTTP status codes</a></li>
<li>W3 - <a href="http://www.w3.org/Protocols/HTTP/HTRESP.html">Historic Status Codes</a></li>
<li><a href="https://svn.tools.ietf.org/svn/wg/httpbis/draft-ietf-httpbis/latest/p2-semantics.html#considerations.for.new.status.codes">Considerations for new Status Codes</a></li>
<li>IANA - <a href="http://uploads.askapache.com/2013/04/http-status-codes.xml">Hypertext Transfer Protocol (HTTP) Status Code Registry</a></li>
<li>Wireshark - <a href="http://uploads.askapache.com/2013/04/packet-http.c">packet-http.c</a></li>
<li><a href="http://www.mnot.net/javascript/xmlhttprequest/">XMLHttpRequest Tests</a></li>
</ul>


<p><a rel="follow" href="http://www.askapache.com/net/http-status-codes.html"></a> &hellip;<a href="http://www.askapache.com/net/http-status-codes.html">HTTP Status Codes</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/net/http-status-codes.html">HTTP Status Codes</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/zErbt4nFcBo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/net/http-status-codes.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.askapache.com/net/http-status-codes.html</feedburner:origLink></item>
		<item>
		<title>View all MySQL Variables for Pasting into my.cnf</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/BehaZiy1ePU/view-mysql-variables-my-cnf.html</link>
		<comments>http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html#comments</comments>
		<pubDate>Fri, 05 Apr 2013 18:40:50 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[/etc/my.cnf]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[column]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[tr]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=8254</guid>
		<description><![CDATA[<p><p><a class="IFL" href="/mysql/view-mysql-variables-my-cnf.html"><img src="http://uploads.askapache.com/2013/04/mysql-variables-my-cnf-file-300x106.png" alt="mysql-variables-my-cnf-file" width="300" height="106" class="alignnone size-medium wp-image-8268" /></a>This is really useful for me because I work with dozens of different database servers.  The first thing I do is run this command and paste it into the servers <code>/etc/my.cnf</code> file.  That way I will always know the original value and it just makes life much easier.<br class="C" /></p>
<pre>$ mysql -NBe &#039;SHOW VARIABLES&#039; &#124;sed &#039;s,\t,^=,&#039;&#124;column -ts^&#124;tr "\n" &#039;@&#039;&#124;eval $(echo "sed &#039;" "s,@\("{a..z}"\),\n\n\1,;" "&#039;")&#124;tr &#039;@&#039; "\n"&#124;sed &#039;s,^,# ,g&#039;</pre>
</p><p>The post <a href="http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html">View all MySQL Variables for Pasting into my.cnf</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a rel="index" href="http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html"></a><a href="http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html"><cite>AskApache.com</cite></a></p><p>This is really useful for me because I work with dozens of different database servers.  The first thing I do is run this command and paste it into the servers <code>/etc/my.cnf</code> file.  That way I will always know the original value and it just makes life much easier.</p>


<h2>Command to run in Shell</h2>
<pre>
$ mysql -NBe &#039;SHOW VARIABLES&#039; | sed &#039;s,\t,^=,&#039; | column -ts^ | tr "\n" &#039;@&#039; | eval $(echo "sed &#039;" "s,@\("{a..z}"\),\n\n\1,;" "&#039;") | tr &#039;@&#039; "\n" | sed &#039;s,^,# ,g&#039;
</pre>

<h3>Command Breakdown</h3>
<ol>
<li>Show all Variables using Batch Mode<br /><code>mysql -NBe &#039;SHOW VARIABLES&#039;</code></li>
<li>Remove tabs and add the '^='<br /><code>sed &#039;s,\t,^=,&#039;</code></li>
<li>Align the left column of varnames and the right column of values<br /><code>column -ts^</code></li>
<li>Replace the end-of-line with '@'<br /><code>tr "\n" &#039;@&#039;</code></li>
<li>Add 3 blank lines before the first occurance of each letter in the alphabet<br /><code>eval $(echo "sed &#039;" "s,@\("{a..z}"\),\n\n\1,;" "&#039;")</code></li>
<li>Replace '@' with newlines<br /><code>tr &#039;@&#039; "\n"</code></li>
<li>Make every line commented by '# '<br /><code>sed &#039;s,^,# ,g&#039;</code></li>
</ol>

<h2>MySql Variables Commented</h2>
<p>Paste this into your servers <code>/etc/my.cnf</code> file.</p>
<p><img src="http://uploads.askapache.com/2013/04/mysql-variables-my-cnf-file.png" alt="View all MySQL Variables for Pasting into my.cnf" width="690" height="246" class="alignnone size-full wp-image-8268" title="mysql variables my cnf file" /><p>
<pre>
# auto_increment_increment                           = 1
#
#
# auto_increment_offset                              = 1
# autocommit                                         = ON
# automatic_sp_privileges                            = ON
#
#
# back_log                                           = 100
# basedir                                            = /usr
# big_tables                                         = OFF
# binlog_cache_size                                  = 32768
# binlog_direct_non_transactional_updates            = OFF
# binlog_format                                      = STATEMENT
# binlog_stmt_cache_size                             = 32768
# bulk_insert_buffer_size                            = 8388608
#
#
# character_set_client                               = latin1
# character_set_connection                           = latin1
# character_set_database                             = utf8
# character_set_filesystem                           = binary
# character_set_results                              = latin1
# character_set_server                               = utf8
# character_set_system                               = utf8
# character_sets_dir                                 = /usr/share/mysql/charsets/
# collation_connection                               = latin1_swedish_ci
# collation_database                                 = utf8_general_ci
# collation_server                                   = utf8_general_ci
# completion_type                                    = NO_CHAIN
# concurrent_insert                                  = AUTO
# connect_timeout                                    = 10
#
#
# datadir                                            = /var/lib/mysql/
# date_format                                        = %Y-%m-%d
# datetime_format                                    = %Y-%m-%d %H:%i:%s
# default_storage_engine                             = InnoDB
# default_week_format                                = 0
# delay_key_write                                    = ON
# delayed_insert_limit                               = 100
# delayed_insert_timeout                             = 300
# delayed_queue_size                                 = 1000
# div_precision_increment                            = 4
#
#
# engine_condition_pushdown                          = ON
# error_count                                        = 0
# event_scheduler                                    = OFF
# expire_logs_days                                   = 7
# external_user                                      =
#
#
# flush                                              = OFF
# flush_time                                         = 0
# foreign_key_checks                                 = ON
# ft_boolean_syntax                                  = + -&gt;&lt;()~*:""&amp;|
# ft_max_word_len                                    = 84
# ft_min_word_len                                    = 4
# ft_query_expansion_limit                           = 20
# ft_stopword_file                                   = (built-in)
#
#
# general_log                                        = OFF
# general_log_file                                   = /var/lib/mysqllogs/general-log
# group_concat_max_len                               = 1024
#
#
# have_compress                                      = YES
# have_crypt                                         = YES
# have_csv                                           = YES
# have_dynamic_loading                               = YES
# have_geometry                                      = YES
# have_innodb                                        = YES
# have_ndbcluster                                    = NO
# have_openssl                                       = DISABLED
# have_partitioning                                  = YES
# have_profiling                                     = YES
# have_query_cache                                   = YES
# have_rtree_keys                                    = YES
# have_ssl                                           = DISABLED
# have_symlink                                       = YES
# hostname                                           = killerdbees.ouch.node5.net
#
#
# identity                                           = 0
# ignore_builtin_innodb                              = OFF
# init_connect                                       = SET collation_connection = utf8_general_ci,NAMES utf8
# init_file                                          =
# init_slave                                         =
# innodb_adaptive_flushing                           = ON
# innodb_adaptive_hash_index                         = ON
# innodb_additional_mem_pool_size                    = 8388608
# innodb_autoextend_increment                        = 8
# innodb_autoinc_lock_mode                           = 1
# innodb_buffer_pool_instances                       = 1
# innodb_buffer_pool_size                            = 157286400
# innodb_change_buffering                            = all
# innodb_checksums                                   = ON
# innodb_commit_concurrency                          = 0
# innodb_concurrency_tickets                         = 500
# innodb_data_file_path                              = ibdata1:10M:autoextend
# innodb_data_home_dir                               =
# innodb_doublewrite                                 = ON
# innodb_fast_shutdown                               = 1
# innodb_file_format                                 = Antelope
# innodb_file_format_check                           = ON
# innodb_file_format_max                             = Antelope
# innodb_file_per_table                              = OFF
# innodb_flush_log_at_trx_commit                     = 2
# innodb_flush_method                                =
# innodb_force_load_corrupted                        = OFF
# innodb_force_recovery                              = 0
# innodb_io_capacity                                 = 200
# innodb_large_prefix                                = OFF
# innodb_lock_wait_timeout                           = 50
# innodb_locks_unsafe_for_binlog                     = OFF
# innodb_log_buffer_size                             = 8388608
# innodb_log_file_size                               = 5242880
# innodb_log_files_in_group                          = 2
# innodb_log_group_home_dir                          = ./
# innodb_max_dirty_pages_pct                         = 75
# innodb_max_purge_lag                               = 0
# innodb_mirrored_log_groups                         = 1
# innodb_old_blocks_pct                              = 37
# innodb_old_blocks_time                             = 0
# innodb_open_files                                  = 300
# innodb_print_all_deadlocks                         = OFF
# innodb_purge_batch_size                            = 20
# innodb_purge_threads                               = 0
# innodb_random_read_ahead                           = OFF
# innodb_read_ahead_threshold                        = 56
# innodb_read_io_threads                             = 4
# innodb_replication_delay                           = 0
# innodb_rollback_on_timeout                         = OFF
# innodb_rollback_segments                           = 128
# innodb_spin_wait_delay                             = 6
# innodb_stats_method                                = nulls_equal
# innodb_stats_on_metadata                           = ON
# innodb_stats_sample_pages                          = 8
# innodb_strict_mode                                 = OFF
# innodb_support_xa                                  = ON
# innodb_sync_spin_loops                             = 30
# innodb_table_locks                                 = ON
# innodb_thread_concurrency                          = 0
# innodb_thread_sleep_delay                          = 10000
# innodb_use_native_aio                              = ON
# innodb_use_sys_malloc                              = ON
# innodb_version                                     = 5.5.30
# innodb_write_io_threads                            = 4
# insert_id                                          = 0
# interactive_timeout                                = 36000
#
#
# join_buffer_size                                   = 1048576
#
#
# keep_files_on_create                               = OFF
# key_buffer_size                                    = 134217728
# key_cache_age_threshold                            = 300
# key_cache_block_size                               = 1024
# key_cache_division_limit                           = 100
#
#
# large_files_support                                = ON
# large_page_size                                    = 0
# large_pages                                        = OFF
# last_insert_id                                     = 0
# lc_messages                                        = en_US
# lc_messages_dir                                    = /usr/share/mysql/
# lc_time_names                                      = en_US
# license                                            = GPL
# local_infile                                       = ON
# lock_wait_timeout                                  = 31536000
# locked_in_memory                                   = OFF
# log                                                = OFF
# log_bin                                            = ON
# log_bin_trust_function_creators                    = OFF
# log_error                                          = /var/log/mysqld.log
# log_output                                         = FILE
# log_queries_not_using_indexes                      = OFF
# log_slave_updates                                  = OFF
# log_slow_queries                                   = ON
# log_warnings                                       = 1
# long_query_time                                    = 5.000000
# low_priority_updates                               = OFF
# lower_case_file_system                             = OFF
# lower_case_table_names                             = 0
#
#
# max_allowed_packet                                 = 536870912
# max_binlog_cache_size                              = 18446744073709547520
# max_binlog_size                                    = 1073741824
# max_binlog_stmt_cache_size                         = 18446744073709547520
# max_connect_errors                                 = 10000
# max_connections                                    = 500
# max_delayed_threads                                = 20
# max_error_count                                    = 64
# max_heap_table_size                                = 157286400
# max_insert_delayed_threads                         = 20
# max_join_size                                      = 18446744073709551615
# max_length_for_sort_data                           = 1024
# max_long_data_size                                 = 536870912
# max_prepared_stmt_count                            = 16382
# max_relay_log_size                                 = 0
# max_seeks_for_key                                  = 18446744073709551615
# max_sort_length                                    = 1024
# max_sp_recursion_depth                             = 0
# max_tmp_tables                                     = 32
# max_user_connections                               = 0
# max_write_lock_count                               = 18446744073709551615
# metadata_locks_cache_size                          = 1024
# min_examined_row_limit                             = 0
# multi_range_count                                  = 256
# myisam_data_pointer_size                           = 6
# myisam_max_sort_file_size                          = 9223372036853727232
# myisam_mmap_size                                   = 18446744073709551615
# myisam_recover_options                             = OFF
# myisam_repair_threads                              = 1
# myisam_sort_buffer_size                            = 12582912
# myisam_stats_method                                = nulls_unequal
# myisam_use_mmap                                    = OFF
#
#
# net_buffer_length                                  = 16384
# net_read_timeout                                   = 30
# net_retry_count                                    = 10
# net_write_timeout                                  = 60
# new                                                = OFF
#
#
# old                                                = OFF
# old_alter_table                                    = OFF
# old_passwords                                      = OFF
# open_files_limit                                   = 40000
# optimizer_prune_level                              = 1
# optimizer_search_depth                             = 62
#
#
# performance_schema                                 = OFF
# performance_schema_events_waits_history_long_size  = 10000
# performance_schema_events_waits_history_size       = 10
# performance_schema_max_cond_classes                = 80
# performance_schema_max_cond_instances              = 1000
# performance_schema_max_file_classes                = 50
# performance_schema_max_file_handles                = 32768
# performance_schema_max_file_instances              = 10000
# performance_schema_max_mutex_classes               = 200
# performance_schema_max_mutex_instances             = 1000000
# performance_schema_max_rwlock_classes              = 30
# performance_schema_max_rwlock_instances            = 1000000
# performance_schema_max_table_handles               = 100000
# performance_schema_max_table_instances             = 50000
# performance_schema_max_thread_classes              = 50
# performance_schema_max_thread_instances            = 1000
# pid_file                                           = /var/run/mysqld/mysqld.pid
# plugin_dir                                         = /usr/lib64/mysql/plugin/
# port                                               = 3306
# preload_buffer_size                                = 32768
# profiling                                          = OFF
# profiling_history_size                             = 15
# protocol_version                                   = 10
# proxy_user                                         =
# pseudo_slave_mode                                  = OFF
# pseudo_thread_id                                   = 40992
#
#
# query_alloc_block_size                             = 8192
# query_cache_limit                                  = 1048576
# query_cache_min_res_unit                           = 4096
# query_cache_size                                   = 2097152
# query_cache_type                                   = ON
# query_cache_wlock_invalidate                       = OFF
# query_prealloc_size                                = 8192
#
#
# rand_seed1                                         = 0
# rand_seed2                                         = 0
# range_alloc_block_size                             = 4096
# read_buffer_size                                   = 4194304
# read_only                                          = OFF
# read_rnd_buffer_size                               = 5242880
# relay_log                                          =
# relay_log_index                                    =
# relay_log_info_file                                = relay-log.info
# relay_log_purge                                    = ON
# relay_log_recovery                                 = OFF
# relay_log_space_limit                              = 0
# report_host                                        =
# report_password                                    =
# report_port                                        = 3306
# report_user                                        =
# rpl_recovery_rank                                  = 0
#
#
# secure_auth                                        = OFF
# secure_file_priv                                   =
# server_id                                          = 224
# skip_external_locking                              = ON
# skip_name_resolve                                  = ON
# skip_networking                                    = OFF
# skip_show_database                                 = OFF
# slave_compressed_protocol                          = OFF
# slave_exec_mode                                    = STRICT
# slave_load_tmpdir                                  = /var/lib/mysqltmp
# slave_max_allowed_packet                           = 1073741824
# slave_net_timeout                                  = 3600
# slave_skip_errors                                  = OFF
# slave_transaction_retries                          = 10
# slave_type_conversions                             =
# slow_launch_time                                   = 2
# slow_query_log                                     = ON
# slow_query_log_file                                = /var/lib/mysqllogs/slow-log
# socket                                             = /var/lib/mysql/mysql.sock
# sort_buffer_size                                   = 5242880
# sql_auto_is_null                                   = OFF
# sql_big_selects                                    = ON
# sql_big_tables                                     = OFF
# sql_buffer_result                                  = OFF
# sql_log_bin                                        = ON
# sql_log_off                                        = OFF
# sql_low_priority_updates                           = OFF
# sql_max_join_size                                  = 18446744073709551615
# sql_mode                                           = NO_ENGINE_SUBSTITUTION
# sql_notes                                          = ON
# sql_quote_show_create                              = ON
# sql_safe_updates                                   = OFF
# sql_select_limit                                   = 18446744073709551615
# sql_slave_skip_counter                             = 0
# sql_warnings                                       = OFF
# ssl_ca                                             =
# ssl_capath                                         =
# ssl_cert                                           =
# ssl_cipher                                         =
# ssl_key                                            =
# storage_engine                                     = InnoDB
# stored_program_cache                               = 256
# sync_binlog                                        = 0
# sync_frm                                           = ON
# sync_master_info                                   = 0
# sync_relay_log                                     = 0
# sync_relay_log_info                                = 0
# system_time_zone                                   = EDT
#
#
# table_definition_cache                             = 1200
# table_open_cache                                   = 1000
# thread_cache_size                                  = 150
# thread_concurrency                                 = 10
# thread_handling                                    = one-thread-per-connection
# thread_stack                                       = 262144
# time_format                                        = %H:%i:%s
# time_zone                                          = SYSTEM
# timed_mutexes                                      = OFF
# timestamp                                          = 1365185527
# tmp_table_size                                     = 157286400
# tmpdir                                             = /var/lib/mysqltmp
# transaction_alloc_block_size                       = 8192
# transaction_prealloc_size                          = 4096
# tx_isolation                                       = REPEATABLE-READ
#
#
# unique_checks                                      = ON
# updatable_views_with_limit                         = YES
#
#
# version                                            = 5.5.30-log
# version_comment                                    = Distributed by The IUS Community Project
# version_compile_machine                            = x86_64
# version_compile_os                                 = Linux
#
#
# wait_timeout                                       = 36000
# warning_count                                      = 0
</pre>





<h2>MySQL Variables Listing</h2>
<p>Just a listing of the ones being used on my killerdbees server.</p>
<dl>
<dt><var>auto_increment_increment</var></dt><dd>1</dd>
<dt><var>auto_increment_offset</var></dt><dd>1</dd>
<dt><var>autocommit</var></dt><dd>ON</dd>
<dt><var>automatic_sp_privileges</var></dt><dd>ON</dd>
<dt><var>back_log</var></dt><dd>100</dd>
<dt><var>basedir</var></dt><dd>/usr</dd>
<dt><var>big_tables</var></dt><dd>OFF</dd>
<dt><var>binlog_cache_size</var></dt><dd>32768</dd>
<dt><var>binlog_direct_non_transactional_updates</var></dt><dd>OFF</dd>
<dt><var>binlog_format</var></dt><dd>STATEMENT</dd>
<dt><var>binlog_stmt_cache_size</var></dt><dd>32768</dd>
<dt><var>bulk_insert_buffer_size</var></dt><dd>8388608</dd>
<dt><var>character_set_client</var></dt><dd>latin1</dd>
<dt><var>character_set_connection</var></dt><dd>latin1</dd>
<dt><var>character_set_database</var></dt><dd>utf8</dd>
<dt><var>character_set_filesystem</var></dt><dd>binary</dd>
<dt><var>character_set_results</var></dt><dd>latin1</dd>
<dt><var>character_set_server</var></dt><dd>utf8</dd>
<dt><var>character_set_system</var></dt><dd>utf8</dd>
<dt><var>character_sets_dir</var></dt><dd>/usr/share/mysql/charsets/</dd>
<dt><var>collation_connection</var></dt><dd>latin1_swedish_ci</dd>
<dt><var>collation_database</var></dt><dd>utf8_general_ci</dd>
<dt><var>collation_server</var></dt><dd>utf8_general_ci</dd>
<dt><var>completion_type</var></dt><dd>NO_CHAIN</dd>
<dt><var>concurrent_insert</var></dt><dd>AUTO</dd>
<dt><var>connect_timeout</var></dt><dd>10</dd>
<dt><var>datadir</var></dt><dd>/var/lib/mysql/</dd>
<dt><var>date_format</var></dt><dd>%Y-%m-%d</dd>
<dt><var>datetime_format</var></dt><dd>%Y-%m-%d %H:%i:%s</dd>
<dt><var>default_storage_engine</var></dt><dd>InnoDB</dd>
<dt><var>default_week_format</var></dt><dd>0</dd>
<dt><var>delay_key_write</var></dt><dd>ON</dd>
<dt><var>delayed_insert_limit</var></dt><dd>100</dd>
<dt><var>delayed_insert_timeout</var></dt><dd>300</dd>
<dt><var>delayed_queue_size</var></dt><dd>1000</dd>
<dt><var>div_precision_increment</var></dt><dd>4</dd>
<dt><var>engine_condition_pushdown</var></dt><dd>ON</dd>
<dt><var>error_count</var></dt><dd>0</dd>
<dt><var>event_scheduler</var></dt><dd>OFF</dd>
<dt><var>expire_logs_days</var></dt><dd>7</dd>
<dt><var>external_user</var></dt><dd></dd>
<dt><var>flush</var></dt><dd>OFF</dd>
<dt><var>flush_time</var></dt><dd>0</dd>
<dt><var>foreign_key_checks</var></dt><dd>ON</dd>
<dt><var>ft_boolean_syntax</var></dt><dd>+ -><()~*:""&|</dd>
<dt><var>ft_max_word_len</var></dt><dd>84</dd>
<dt><var>ft_min_word_len</var></dt><dd>4</dd>
<dt><var>ft_query_expansion_limit</var></dt><dd>20</dd>
<dt><var>ft_stopword_file</var></dt><dd>(built-in)</dd>
<dt><var>general_log</var></dt><dd>OFF</dd>
<dt><var>general_log_file</var></dt><dd>/var/lib/mysqllogs/general-log</dd>
<dt><var>group_concat_max_len</var></dt><dd>1024</dd>
<dt><var>have_compress</var></dt><dd>YES</dd>
<dt><var>have_crypt</var></dt><dd>YES</dd>
<dt><var>have_csv</var></dt><dd>YES</dd>
<dt><var>have_dynamic_loading</var></dt><dd>YES</dd>
<dt><var>have_geometry</var></dt><dd>YES</dd>
<dt><var>have_innodb</var></dt><dd>YES</dd>
<dt><var>have_ndbcluster</var></dt><dd>NO</dd>
<dt><var>have_openssl</var></dt><dd>DISABLED</dd>
<dt><var>have_partitioning</var></dt><dd>YES</dd>
<dt><var>have_profiling</var></dt><dd>YES</dd>
<dt><var>have_query_cache</var></dt><dd>YES</dd>
<dt><var>have_rtree_keys</var></dt><dd>YES</dd>
<dt><var>have_ssl</var></dt><dd>DISABLED</dd>
<dt><var>have_symlink</var></dt><dd>YES</dd>
<dt><var>hostname</var></dt><dd>killerdbees.ouch.node5.net</dd>
<dt><var>identity</var></dt><dd>0</dd>
<dt><var>ignore_builtin_innodb</var></dt><dd>OFF</dd>
<dt><var>init_connect</var></dt><dd>SET collation_connection = utf8_general_ci,NAMES utf8</dd>
<dt><var>init_file</var></dt><dd></dd>
<dt><var>init_slave</var></dt><dd></dd>
<dt><var>innodb_adaptive_flushing</var></dt><dd>ON</dd>
<dt><var>innodb_adaptive_hash_index</var></dt><dd>ON</dd>
<dt><var>innodb_additional_mem_pool_size</var></dt><dd>8388608</dd>
<dt><var>innodb_autoextend_increment</var></dt><dd>8</dd>
<dt><var>innodb_autoinc_lock_mode</var></dt><dd>1</dd>
<dt><var>innodb_buffer_pool_instances</var></dt><dd>1</dd>
<dt><var>innodb_buffer_pool_size</var></dt><dd>157286400</dd>
<dt><var>innodb_change_buffering</var></dt><dd>all</dd>
<dt><var>innodb_checksums</var></dt><dd>ON</dd>
<dt><var>innodb_commit_concurrency</var></dt><dd>0</dd>
<dt><var>innodb_concurrency_tickets</var></dt><dd>500</dd>
<dt><var>innodb_data_file_path</var></dt><dd>ibdata1:10M:autoextend</dd>
<dt><var>innodb_data_home_dir</var></dt><dd></dd>
<dt><var>innodb_doublewrite</var></dt><dd>ON</dd>
<dt><var>innodb_fast_shutdown</var></dt><dd>1</dd>
<dt><var>innodb_file_format</var></dt><dd>Antelope</dd>
<dt><var>innodb_file_format_check</var></dt><dd>ON</dd>
<dt><var>innodb_file_format_max</var></dt><dd>Antelope</dd>
<dt><var>innodb_file_per_table</var></dt><dd>OFF</dd>
<dt><var>innodb_flush_log_at_trx_commit</var></dt><dd>2</dd>
<dt><var>innodb_flush_method</var></dt><dd></dd>
<dt><var>innodb_force_load_corrupted</var></dt><dd>OFF</dd>
<dt><var>innodb_force_recovery</var></dt><dd>0</dd>
<dt><var>innodb_io_capacity</var></dt><dd>200</dd>
<dt><var>innodb_large_prefix</var></dt><dd>OFF</dd>
<dt><var>innodb_lock_wait_timeout</var></dt><dd>50</dd>
<dt><var>innodb_locks_unsafe_for_binlog</var></dt><dd>OFF</dd>
<dt><var>innodb_log_buffer_size</var></dt><dd>8388608</dd>
<dt><var>innodb_log_file_size</var></dt><dd>5242880</dd>
<dt><var>innodb_log_files_in_group</var></dt><dd>2</dd>
<dt><var>innodb_log_group_home_dir</var></dt><dd>./</dd>
<dt><var>innodb_max_dirty_pages_pct</var></dt><dd>75</dd>
<dt><var>innodb_max_purge_lag</var></dt><dd>0</dd>
<dt><var>innodb_mirrored_log_groups</var></dt><dd>1</dd>
<dt><var>innodb_old_blocks_pct</var></dt><dd>37</dd>
<dt><var>innodb_old_blocks_time</var></dt><dd>0</dd>
<dt><var>innodb_open_files</var></dt><dd>300</dd>
<dt><var>innodb_print_all_deadlocks</var></dt><dd>OFF</dd>
<dt><var>innodb_purge_batch_size</var></dt><dd>20</dd>
<dt><var>innodb_purge_threads</var></dt><dd>0</dd>
<dt><var>innodb_random_read_ahead</var></dt><dd>OFF</dd>
<dt><var>innodb_read_ahead_threshold</var></dt><dd>56</dd>
<dt><var>innodb_read_io_threads</var></dt><dd>4</dd>
<dt><var>innodb_replication_delay</var></dt><dd>0</dd>
<dt><var>innodb_rollback_on_timeout</var></dt><dd>OFF</dd>
<dt><var>innodb_rollback_segments</var></dt><dd>128</dd>
<dt><var>innodb_spin_wait_delay</var></dt><dd>6</dd>
<dt><var>innodb_stats_method</var></dt><dd>nulls_equal</dd>
<dt><var>innodb_stats_on_metadata</var></dt><dd>ON</dd>
<dt><var>innodb_stats_sample_pages</var></dt><dd>8</dd>
<dt><var>innodb_strict_mode</var></dt><dd>OFF</dd>
<dt><var>innodb_support_xa</var></dt><dd>ON</dd>
<dt><var>innodb_sync_spin_loops</var></dt><dd>30</dd>
<dt><var>innodb_table_locks</var></dt><dd>ON</dd>
<dt><var>innodb_thread_concurrency</var></dt><dd>0</dd>
<dt><var>innodb_thread_sleep_delay</var></dt><dd>10000</dd>
<dt><var>innodb_use_native_aio</var></dt><dd>ON</dd>
<dt><var>innodb_use_sys_malloc</var></dt><dd>ON</dd>
<dt><var>innodb_version</var></dt><dd>5.5.30</dd>
<dt><var>innodb_write_io_threads</var></dt><dd>4</dd>
<dt><var>insert_id</var></dt><dd>0</dd>
<dt><var>interactive_timeout</var></dt><dd>36000</dd>
<dt><var>join_buffer_size</var></dt><dd>1048576</dd>
<dt><var>keep_files_on_create</var></dt><dd>OFF</dd>
<dt><var>key_buffer_size</var></dt><dd>134217728</dd>
<dt><var>key_cache_age_threshold</var></dt><dd>300</dd>
<dt><var>key_cache_block_size</var></dt><dd>1024</dd>
<dt><var>key_cache_division_limit</var></dt><dd>100</dd>
<dt><var>large_files_support</var></dt><dd>ON</dd>
<dt><var>large_page_size</var></dt><dd>0</dd>
<dt><var>large_pages</var></dt><dd>OFF</dd>
<dt><var>last_insert_id</var></dt><dd>0</dd>
<dt><var>lc_messages</var></dt><dd>en_US</dd>
<dt><var>lc_messages_dir</var></dt><dd>/usr/share/mysql/</dd>
<dt><var>lc_time_names</var></dt><dd>en_US</dd>
<dt><var>license</var></dt><dd>GPL</dd>
<dt><var>local_infile</var></dt><dd>ON</dd>
<dt><var>lock_wait_timeout</var></dt><dd>31536000</dd>
<dt><var>locked_in_memory</var></dt><dd>OFF</dd>
<dt><var>log</var></dt><dd>OFF</dd>
<dt><var>log_bin</var></dt><dd>ON</dd>
<dt><var>log_bin_trust_function_creators</var></dt><dd>OFF</dd>
<dt><var>log_error</var></dt><dd>/var/log/mysqld.log</dd>
<dt><var>log_output</var></dt><dd>FILE</dd>
<dt><var>log_queries_not_using_indexes</var></dt><dd>OFF</dd>
<dt><var>log_slave_updates</var></dt><dd>OFF</dd>
<dt><var>log_slow_queries</var></dt><dd>ON</dd>
<dt><var>log_warnings</var></dt><dd>1</dd>
<dt><var>long_query_time</var></dt><dd>5.000000</dd>
<dt><var>low_priority_updates</var></dt><dd>OFF</dd>
<dt><var>lower_case_file_system</var></dt><dd>OFF</dd>
<dt><var>lower_case_table_names</var></dt><dd>0</dd>
<dt><var>max_allowed_packet</var></dt><dd>536870912</dd>
<dt><var>max_binlog_cache_size</var></dt><dd>18446744073709547520</dd>
<dt><var>max_binlog_size</var></dt><dd>1073741824</dd>
<dt><var>max_binlog_stmt_cache_size</var></dt><dd>18446744073709547520</dd>
<dt><var>max_connect_errors</var></dt><dd>10000</dd>
<dt><var>max_connections</var></dt><dd>500</dd>
<dt><var>max_delayed_threads</var></dt><dd>20</dd>
<dt><var>max_error_count</var></dt><dd>64</dd>
<dt><var>max_heap_table_size</var></dt><dd>157286400</dd>
<dt><var>max_insert_delayed_threads</var></dt><dd>20</dd>
<dt><var>max_join_size</var></dt><dd>18446744073709551615</dd>
<dt><var>max_length_for_sort_data</var></dt><dd>1024</dd>
<dt><var>max_long_data_size</var></dt><dd>536870912</dd>
<dt><var>max_prepared_stmt_count</var></dt><dd>16382</dd>
<dt><var>max_relay_log_size</var></dt><dd>0</dd>
<dt><var>max_seeks_for_key</var></dt><dd>18446744073709551615</dd>
<dt><var>max_sort_length</var></dt><dd>1024</dd>
<dt><var>max_sp_recursion_depth</var></dt><dd>0</dd>
<dt><var>max_tmp_tables</var></dt><dd>32</dd>
<dt><var>max_user_connections</var></dt><dd>0</dd>
<dt><var>max_write_lock_count</var></dt><dd>18446744073709551615</dd>
<dt><var>metadata_locks_cache_size</var></dt><dd>1024</dd>
<dt><var>min_examined_row_limit</var></dt><dd>0</dd>
<dt><var>multi_range_count</var></dt><dd>256</dd>
<dt><var>myisam_data_pointer_size</var></dt><dd>6</dd>
<dt><var>myisam_max_sort_file_size</var></dt><dd>9223372036853727232</dd>
<dt><var>myisam_mmap_size</var></dt><dd>18446744073709551615</dd>
<dt><var>myisam_recover_options</var></dt><dd>OFF</dd>
<dt><var>myisam_repair_threads</var></dt><dd>1</dd>
<dt><var>myisam_sort_buffer_size</var></dt><dd>12582912</dd>
<dt><var>myisam_stats_method</var></dt><dd>nulls_unequal</dd>
<dt><var>myisam_use_mmap</var></dt><dd>OFF</dd>
<dt><var>net_buffer_length</var></dt><dd>16384</dd>
<dt><var>net_read_timeout</var></dt><dd>30</dd>
<dt><var>net_retry_count</var></dt><dd>10</dd>
<dt><var>net_write_timeout</var></dt><dd>60</dd>
<dt><var>new</var></dt><dd>OFF</dd>
<dt><var>old</var></dt><dd>OFF</dd>
<dt><var>old_alter_table</var></dt><dd>OFF</dd>
<dt><var>old_passwords</var></dt><dd>OFF</dd>
<dt><var>open_files_limit</var></dt><dd>40000</dd>
<dt><var>optimizer_prune_level</var></dt><dd>1</dd>
<dt><var>optimizer_search_depth</var></dt><dd>62</dd>
<dt><var>optimizer_switch</var></dt><dd>index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on</dd>
<dt><var>performance_schema</var></dt><dd>OFF</dd>
<dt><var>performance_schema_events_waits_history_long_size</var></dt><dd>10000</dd>
<dt><var>performance_schema_events_waits_history_size</var></dt><dd>10</dd>
<dt><var>performance_schema_max_cond_classes</var></dt><dd>80</dd>
<dt><var>performance_schema_max_cond_instances</var></dt><dd>1000</dd>
<dt><var>performance_schema_max_file_classes</var></dt><dd>50</dd>
<dt><var>performance_schema_max_file_handles</var></dt><dd>32768</dd>
<dt><var>performance_schema_max_file_instances</var></dt><dd>10000</dd>
<dt><var>performance_schema_max_mutex_classes</var></dt><dd>200</dd>
<dt><var>performance_schema_max_mutex_instances</var></dt><dd>1000000</dd>
<dt><var>performance_schema_max_rwlock_classes</var></dt><dd>30</dd>
<dt><var>performance_schema_max_rwlock_instances</var></dt><dd>1000000</dd>
<dt><var>performance_schema_max_table_handles</var></dt><dd>100000</dd>
<dt><var>performance_schema_max_table_instances</var></dt><dd>50000</dd>
<dt><var>performance_schema_max_thread_classes</var></dt><dd>50</dd>
<dt><var>performance_schema_max_thread_instances</var></dt><dd>1000</dd>
<dt><var>pid_file</var></dt><dd>/var/run/mysqld/mysqld.pid</dd>
<dt><var>plugin_dir</var></dt><dd>/usr/lib64/mysql/plugin/</dd>
<dt><var>port</var></dt><dd>3306</dd>
<dt><var>preload_buffer_size</var></dt><dd>32768</dd>
<dt><var>profiling</var></dt><dd>OFF</dd>
<dt><var>profiling_history_size</var></dt><dd>15</dd>
<dt><var>protocol_version</var></dt><dd>10</dd>
<dt><var>proxy_user</var></dt><dd></dd>
<dt><var>pseudo_slave_mode</var></dt><dd>OFF</dd>
<dt><var>pseudo_thread_id</var></dt><dd>40992</dd>
<dt><var>query_alloc_block_size</var></dt><dd>8192</dd>
<dt><var>query_cache_limit</var></dt><dd>1048576</dd>
<dt><var>query_cache_min_res_unit</var></dt><dd>4096</dd>
<dt><var>query_cache_size</var></dt><dd>2097152</dd>
<dt><var>query_cache_type</var></dt><dd>ON</dd>
<dt><var>query_cache_wlock_invalidate</var></dt><dd>OFF</dd>
<dt><var>query_prealloc_size</var></dt><dd>8192</dd>
<dt><var>rand_seed1</var></dt><dd>0</dd>
<dt><var>rand_seed2</var></dt><dd>0</dd>
<dt><var>range_alloc_block_size</var></dt><dd>4096</dd>
<dt><var>read_buffer_size</var></dt><dd>4194304</dd>
<dt><var>read_only</var></dt><dd>OFF</dd>
<dt><var>read_rnd_buffer_size</var></dt><dd>5242880</dd>
<dt><var>relay_log</var></dt><dd></dd>
<dt><var>relay_log_index</var></dt><dd></dd>
<dt><var>relay_log_info_file</var></dt><dd>relay-log.info</dd>
<dt><var>relay_log_purge</var></dt><dd>ON</dd>
<dt><var>relay_log_recovery</var></dt><dd>OFF</dd>
<dt><var>relay_log_space_limit</var></dt><dd>0</dd>
<dt><var>report_host</var></dt><dd></dd>
<dt><var>report_password</var></dt><dd></dd>
<dt><var>report_port</var></dt><dd>3306</dd>
<dt><var>report_user</var></dt><dd></dd>
<dt><var>rpl_recovery_rank</var></dt><dd>0</dd>
<dt><var>secure_auth</var></dt><dd>OFF</dd>
<dt><var>secure_file_priv</var></dt><dd></dd>
<dt><var>server_id</var></dt><dd>224</dd>
<dt><var>skip_external_locking</var></dt><dd>ON</dd>
<dt><var>skip_name_resolve</var></dt><dd>ON</dd>
<dt><var>skip_networking</var></dt><dd>OFF</dd>
<dt><var>skip_show_database</var></dt><dd>OFF</dd>
<dt><var>slave_compressed_protocol</var></dt><dd>OFF</dd>
<dt><var>slave_exec_mode</var></dt><dd>STRICT</dd>
<dt><var>slave_load_tmpdir</var></dt><dd>/var/lib/mysqltmp</dd>
<dt><var>slave_max_allowed_packet</var></dt><dd>1073741824</dd>
<dt><var>slave_net_timeout</var></dt><dd>3600</dd>
<dt><var>slave_skip_errors</var></dt><dd>OFF</dd>
<dt><var>slave_transaction_retries</var></dt><dd>10</dd>
<dt><var>slave_type_conversions</var></dt><dd></dd>
<dt><var>slow_launch_time</var></dt><dd>2</dd>
<dt><var>slow_query_log</var></dt><dd>ON</dd>
<dt><var>slow_query_log_file</var></dt><dd>/var/lib/mysqllogs/slow-log</dd>
<dt><var>socket</var></dt><dd>/var/lib/mysql/mysql.sock</dd>
<dt><var>sort_buffer_size</var></dt><dd>5242880</dd>
<dt><var>sql_auto_is_null</var></dt><dd>OFF</dd>
<dt><var>sql_big_selects</var></dt><dd>ON</dd>
<dt><var>sql_big_tables</var></dt><dd>OFF</dd>
<dt><var>sql_buffer_result</var></dt><dd>OFF</dd>
<dt><var>sql_log_bin</var></dt><dd>ON</dd>
<dt><var>sql_log_off</var></dt><dd>OFF</dd>
<dt><var>sql_low_priority_updates</var></dt><dd>OFF</dd>
<dt><var>sql_max_join_size</var></dt><dd>18446744073709551615</dd>
<dt><var>sql_mode</var></dt><dd>NO_ENGINE_SUBSTITUTION</dd>
<dt><var>sql_notes</var></dt><dd>ON</dd>
<dt><var>sql_quote_show_create</var></dt><dd>ON</dd>
<dt><var>sql_safe_updates</var></dt><dd>OFF</dd>
<dt><var>sql_select_limit</var></dt><dd>18446744073709551615</dd>
<dt><var>sql_slave_skip_counter</var></dt><dd>0</dd>
<dt><var>sql_warnings</var></dt><dd>OFF</dd>
<dt><var>ssl_ca</var></dt><dd></dd>
<dt><var>ssl_capath</var></dt><dd></dd>
<dt><var>ssl_cert</var></dt><dd></dd>
<dt><var>ssl_cipher</var></dt><dd></dd>
<dt><var>ssl_key</var></dt><dd></dd>
<dt><var>storage_engine</var></dt><dd>InnoDB</dd>
<dt><var>stored_program_cache</var></dt><dd>256</dd>
<dt><var>sync_binlog</var></dt><dd>0</dd>
<dt><var>sync_frm</var></dt><dd>ON</dd>
<dt><var>sync_master_info</var></dt><dd>0</dd>
<dt><var>sync_relay_log</var></dt><dd>0</dd>
<dt><var>sync_relay_log_info</var></dt><dd>0</dd>
<dt><var>system_time_zone</var></dt><dd>EDT</dd>
<dt><var>table_definition_cache</var></dt><dd>1200</dd>
<dt><var>table_open_cache</var></dt><dd>1000</dd>
<dt><var>thread_cache_size</var></dt><dd>150</dd>
<dt><var>thread_concurrency</var></dt><dd>10</dd>
<dt><var>thread_handling</var></dt><dd>one-thread-per-connection</dd>
<dt><var>thread_stack</var></dt><dd>262144</dd>
<dt><var>time_format</var></dt><dd>%H:%i:%s</dd>
<dt><var>time_zone</var></dt><dd>SYSTEM</dd>
<dt><var>timed_mutexes</var></dt><dd>OFF</dd>
<dt><var>timestamp</var></dt><dd>1365185527</dd>
<dt><var>tmp_table_size</var></dt><dd>157286400</dd>
<dt><var>tmpdir</var></dt><dd>/var/lib/mysqltmp</dd>
<dt><var>transaction_alloc_block_size</var></dt><dd>8192</dd>
<dt><var>transaction_prealloc_size</var></dt><dd>4096</dd>
<dt><var>tx_isolation</var></dt><dd>REPEATABLE-READ</dd>
<dt><var>unique_checks</var></dt><dd>ON</dd>
<dt><var>updatable_views_with_limit</var></dt><dd>YES</dd>
<dt><var>version</var></dt><dd>5.5.30-log</dd>
<dt><var>version_comment</var></dt><dd>Distributed by The IUS Community Project</dd>
<dt><var>version_compile_machine</var></dt><dd>x86_64</dd>
<dt><var>version_compile_os</var></dt><dd>Linux</dd>
<dt><var>wait_timeout</var></dt><dd>36000</dd>
<dt><var>warning_count</var></dt><dd>0</dd>
</dl><p><a rel="follow" href="http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html"></a> &hellip;<a href="http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html">View all MySQL Variables for Pasting into my.cnf</a>&hellip; originally appeared on <cite>AskApache.com</cite></p><p>The post <a href="http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html">View all MySQL Variables for Pasting into my.cnf</a> appeared first on <a href="http://www.askapache.com">AskApache</a>.</p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/BehaZiy1ePU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html</feedburner:origLink></item>
	</channel>
</rss>
