<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>AskApache &#187; Apache</title>
	<atom:link href="http://www.askapache.com/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.askapache.com</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Fri, 25 Jun 2010 00:55:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Session File Hacks</title>
		<link>http://www.askapache.com/php/php-session-hack.html</link>
		<comments>http://www.askapache.com/php/php-session-hack.html#comments</comments>
		<pubDate>Fri, 25 Jun 2010 00:00:09 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Sessions]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[umask]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=1019</guid>
		<description><![CDATA[<p><strong>What they say about kung-fu is true</strong>..</p>
<p>It can be attained by anyone through <em>hard work over time</em>.   You can become as good as the amount of work you put in.   Here's a short look at a basic technique that I use.  Simply reverse engineering the source code and taking notes along the way...</p>
<pre>static void php_session_send_cookie(TSRMLS_D)
  if (SG(headers_sent)) {
          if (output_start_filename) {
                  php_error_docref(NULL TSRMLS_CC, E_WARNING, &#34;Cannot send session cookie - headers already sent by (output started at %s:%d)&#34;,
                          output_start_filename, output_start_lineno);
          } else {
                  php_error_docref(NULL TSRMLS_CC, E_WARNING, &#34;Cannot send session cookie - headers already sent&#34;);
          }
          return;
  }
&#160;
  /* URL encode session_name and id because they might be user supplied */
  e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)), NULL);</pre>]]></description>
			<content:encoded><![CDATA[<p>If you want to learn best tricks and tips, there&#8217;s only one way to do it&#8230; at least only one way that I know of.  Here are some notes I created while learning about the intricacies of php sessions, it&#8217;s all in the code.</p>
<pre>[Session]
; Handler used to store/retrieve data.
session.save_handler = files</pre>
<p>Argument passed to save_handler.  In the case of files, this is the path where data files are stored. As of PHP 4.0.1, you can define the path as:</p>
<pre>session.save_path = &quot;N;/path&quot;</pre>
<p> where N is an integer.  Instead of storing all the session files in<br />
 /path, what this will do is use subdirectories N-levels deep, and<br />
 store the session data in those directories.  This is useful if you<br />
 or your OS have problems with lots of files in one directory, and is<br />
 a more efficient layout for servers that handle lots of sessions.</p>
<pre>;
; NOTE 1: PHP will not create this directory structure automatically.
;         You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
;         use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
;     session.save_path = &quot;N;MODE;/path&quot;
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process&#039;s umask.
;session.save_path = &quot;/tmp&quot;</pre>
<h3>session.c</h3>
<pre>/* {{{ PHP_INI
 */
PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN(&quot;session.bug_compat_42&quot;,    &quot;1&quot;,         PHP_INI_ALL, OnUpdateBool,   bug_compat,         php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.bug_compat_warn&quot;,  &quot;1&quot;,         PHP_INI_ALL, OnUpdateBool,   bug_compat_warn,    php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.save_path&quot;,          &quot;&quot;,          PHP_INI_ALL, OnUpdateSaveDir,save_path,          php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.name&quot;,               &quot;PHPSESSID&quot;, PHP_INI_ALL, OnUpdateString, session_name,       php_ps_globals,    ps_globals)
        PHP_INI_ENTRY(&quot;session.save_handler&quot;,           &quot;files&quot;,     PHP_INI_ALL, OnUpdateSaveHandler)
        STD_PHP_INI_BOOLEAN(&quot;session.auto_start&quot;,       &quot;0&quot;,         PHP_INI_ALL, OnUpdateBool,   auto_start,         php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.gc_probability&quot;,     &quot;1&quot;,         PHP_INI_ALL, OnUpdateLong,    gc_probability,     php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.gc_divisor&quot;,         &quot;100&quot;,       PHP_INI_ALL, OnUpdateLong,    gc_divisor,        php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.gc_maxlifetime&quot;,     &quot;1440&quot;,      PHP_INI_ALL, OnUpdateLong,    gc_maxlifetime,     php_ps_globals,    ps_globals)
        PHP_INI_ENTRY(&quot;session.serialize_handler&quot;,      &quot;php&quot;,       PHP_INI_ALL, OnUpdateSerializer)
        STD_PHP_INI_ENTRY(&quot;session.cookie_lifetime&quot;,    &quot;0&quot;,         PHP_INI_ALL, OnUpdateLong,    cookie_lifetime,    php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cookie_path&quot;,        &quot;/&quot;,         PHP_INI_ALL, OnUpdateString, cookie_path,        php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cookie_domain&quot;,      &quot;&quot;,          PHP_INI_ALL, OnUpdateString, cookie_domain,      php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.cookie_secure&quot;,    &quot;&quot;,          PHP_INI_ALL, OnUpdateBool,   cookie_secure,      php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.cookie_httponly&quot;,  &quot;&quot;,          PHP_INI_ALL, OnUpdateBool,   cookie_httponly,    php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.use_cookies&quot;,      &quot;1&quot;,         PHP_INI_ALL, OnUpdateBool,   use_cookies,        php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.use_only_cookies&quot;, &quot;0&quot;,         PHP_INI_ALL, OnUpdateBool,   use_only_cookies,   php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.referer_check&quot;,      &quot;&quot;,          PHP_INI_ALL, OnUpdateString, extern_referer_chk, php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.entropy_file&quot;,       &quot;&quot;,          PHP_INI_ALL, OnUpdateString, entropy_file,       php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.entropy_length&quot;,     &quot;0&quot;,         PHP_INI_ALL, OnUpdateLong,    entropy_length,     php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cache_limiter&quot;,      &quot;nocache&quot;,   PHP_INI_ALL, OnUpdateString, cache_limiter,      php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cache_expire&quot;,       &quot;180&quot;,       PHP_INI_ALL, OnUpdateLong,    cache_expire,       php_ps_globals,    ps_globals)
        PHP_INI_ENTRY(&quot;session.use_trans_sid&quot;,          &quot;0&quot;,         PHP_INI_ALL, OnUpdateTransSid)
        STD_PHP_INI_ENTRY(&quot;session.hash_function&quot;,      &quot;0&quot;,         PHP_INI_ALL, OnUpdateLong,    hash_func,          php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.hash_bits_per_character&quot;,      &quot;4&quot;,         PHP_INI_ALL, OnUpdateLong,    hash_bits_per_character,          php_ps_globals,    ps_globals)
&nbsp;
        /* Commented out until future discussion */
        /* PHP_INI_ENTRY(&quot;session.encode_sources&quot;, &quot;globals,track&quot;, PHP_INI_ALL, NULL) */
PHP_INI_END()
/* }}} */</pre>
<h3>Session Errors</h3>
<pre>The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and &#039;-,&#039;
fcntl(%d, F_SETFD, FD_CLOEXEC) failed: %s (%d)
open(%s, O_RDWR) failed: %s (%d)
ps_files_cleanup_dir: opendir(%s) failed: %s (%d)
read failed: %s (%d)
read returned less bytes than requested
write failed: %s (%d)
write wrote less bytes than requested
mm_malloc failed, avail %d, err %s
cannot allocate new data segment
Skipping numeric key %ld.
A session is active. You cannot change the session module&#039;s ini settings at this time.
Cannot find save handler %s
Cannot find serialization handler %s
Unknown session.serialize_handler. Failed to encode session object.
Cannot encode non-existent session.
Unknown session.serialize_handler. Failed to decode session object.
Failed to decode session object. Session has been destroyed.
Invalid session hash function
The ini setting hash_bits_per_character is out of range (should be 4, 5, or 6) - using 4 for now
No storage module chosen - failed to initialize session.
Failed to initialize storage module: %s (path: %s)
The session bug compatibility code will not
Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively.
Failed to write session data (%s). Please
Cannot send session cache limiter - headers already sent (output started at %s:%d)
Cannot send session cache limiter - headers already sent
Cannot send session cookie - headers already sent by (output started at %s:%d)
Cannot send session cookie - headers already sent
Cannot find save handler %s
Cannot find unknown save handler
purged %d expired session objects
Trying to destroy uninitialized session
Session object destruction failed
Cannot find named PHP session module (%s)
Argument %d is not a valid callback
Cannot regenerate session id - headers already sent
Session object destruction failed</pre>
<pre>PS_GC_FUNC(files)
{
        PS_FILES_DATA;
&nbsp;
        /* we don&#039;t perform any cleanup, if dirdepth is larger than 0.
           we return SUCCESS, since all cleanup should be handled by
           an external entity (i.e. find -ctime x | xargs rm) */
&nbsp;
        if (data-&gt;dirdepth == 0) {
                *nrdels = ps_files_cleanup_dir(data-&gt;basedir, maxlifetime TSRMLS_CC);
        }
&nbsp;
        return SUCCESS;
}</pre>
<h3>mod_files.c</h3>
<pre>/* If you change the logic here, please also update the error message in
 * ps_files_open() appropriately */
static int ps_files_valid_key(const char *key)
{
        size_t len;
        const char *p;
        char c;
        int ret = 1;
&nbsp;
        for (p = key; (c = *p); p++) {
                /* valid characters are a..z,A..Z,0..9 */
                if (!((c &gt;= &#039;a&#039; &amp;&amp; c &lt;= &#039;z&#039;)
                                || (c &gt;= &#039;A&#039; &amp;&amp; c &lt;= &#039;Z&#039;)
                                || (c &gt;= &#039;0&#039; &amp;&amp; c &lt;= &#039;9&#039;)
                                || c == &#039;,&#039;
                                || c == &#039;-&#039;)) {
                        ret = 0;
                        break;
                }
        }
&nbsp;
        len = p - key;
&nbsp;
        if (len == 0) {
                ret = 0;
        }
&nbsp;
        return ret;
}</pre>
<pre>static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
{
        DIR *dir;
        char dentry[sizeof(struct dirent) + MAXPATHLEN];
        struct dirent *entry = (struct dirent *) &amp;dentry;
        struct stat sbuf;
        char buf[MAXPATHLEN];
        time_t now;
        int nrdels = 0;
        size_t dirname_len;
&nbsp;
        dir = opendir(dirname);
        if (!dir) {
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, &quot;ps_files_cleanup_dir: opendir(%s) failed: %s (%d)&quot;, dirname, strerror(errno), errno);
                return (0);
        }
&nbsp;
        time(&amp;now);
&nbsp;
        dirname_len = strlen(dirname);
&nbsp;
        /* Prepare buffer (dirname never changes) */
        memcpy(buf, dirname, dirname_len);
        buf[dirname_len] = PHP_DIR_SEPARATOR;
&nbsp;
        while (php_readdir_r(dir, (struct dirent *) dentry, &amp;entry) == 0 &amp;&amp; entry) {
                /* does the file start with our prefix? */
                if (!strncmp(entry-&gt;d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1)) {
                        size_t entry_len = strlen(entry-&gt;d_name);
&nbsp;
                        /* does it fit into our buffer? */
                        if (entry_len + dirname_len + 2 &lt; MAXPATHLEN) {
                                /* create the full path.. */
                                memcpy(buf + dirname_len + 1, entry-&gt;d_name, entry_len);
&nbsp;
                                /* NUL terminate it and */
                                buf[dirname_len + entry_len + 1] = &#039;\0&#039;;
&nbsp;
                                /* check whether its last access was more than maxlifet ago */
                                if (VCWD_STAT(buf, &amp;sbuf) == 0 &amp;&amp;
#ifdef NETWARE
                                                (now - sbuf.st_mtime.tv_sec) &gt; maxlifetime) {
#else
                                                (now - sbuf.st_mtime) &gt; maxlifetime) {
#endif
                                        VCWD_UNLINK(buf);
                                        nrdels++;
                                }
                        }
                }
        }
&nbsp;
        closedir(dir);
&nbsp;
        return (nrdels);
}</pre>
<h3>ext/session/mod_files.c</h3>
<pre>#define PS_FILES_DATA ps_files *data = PS_GET_MOD_DATA()
&nbsp;
PS_OPEN_FUNC(files)
{
        ps_files *data;
        const char *p, *last;
        const char *argv[3];
        int argc = 0;
        size_t dirdepth = 0;
        int filemode = 0600;
&nbsp;
        if (*save_path == &#039;\0&#039;) {
                /* if save path is an empty string, determine the temporary dir */
                save_path = php_get_temporary_directory();
&nbsp;
                if (strcmp(save_path, &quot;/tmp&quot;)) {
                        if (PG(safe_mode) &amp;&amp; (!php_checkuid(save_path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
                                return FAILURE;
                        }
                        if (php_check_open_basedir(save_path TSRMLS_CC)) {
                                return FAILURE;
                        }
                }
        }
&nbsp;
        /* split up input parameter */
        last = save_path;
        p = strchr(save_path, &#039;;&#039;);
        while (p) {
                argv[argc++] = last;
                last = ++p;
                p = strchr(p, &#039;;&#039;);
                if (argc &gt; 2) break;
        }
        argv[argc++] = last;
&nbsp;
        if (argc &gt; 1) {
                errno = 0;
                dirdepth = (size_t) strtol(argv[0], NULL, 10);
                if (errno == ERANGE) {
                        php_error(E_WARNING, &quot;The first parameter in session.save_path is invalid&quot;);
                        return FAILURE;
                }
        }
&nbsp;
        if (argc &gt; 2) {
                errno = 0;
                filemode = strtol(argv[1], NULL, 8);
                if (errno == ERANGE || filemode &lt; 0 || filemode &gt; 07777) {
                        php_error(E_WARNING, &quot;The second parameter in session.save_path is invalid&quot;);
                        return FAILURE;
                }
        }
        save_path = argv[argc - 1];
&nbsp;
        data = emalloc(sizeof(*data));
        memset(data, 0, sizeof(*data));
&nbsp;
        data-&gt;fd = -1;
        data-&gt;dirdepth = dirdepth;
        data-&gt;filemode = filemode;
        data-&gt;basedir_len = strlen(save_path);
        data-&gt;basedir = estrndup(save_path, data-&gt;basedir_len);
&nbsp;
        PS_SET_MOD_DATA(data);
&nbsp;
        return SUCCESS;
}</pre>
<blockquote><pre>[PHP 5.2.0 session.save_path safe_mode and open_basedir bypass]
&nbsp;
Author: Maksymilian Arciemowicz (SecurityReason)
Date:
- - Written: 02.10.2006
- - Public: 08.12.2006
SecurityAlert Id: 43
CVE: CVE-2006-6383
SecurityRisk: High
Affected Software: PHP 5.2.0
Advisory URL: http://securityreason.com/achievement_securityalert/43
Vendor: http://www.php.net
&nbsp;
- &#45;&#45;- 0.Description &#45;&#45;-
PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from
C, Java and Perl with a couple of unique PHP-specific features thrown in. The
goal of the language is to allow web developers to write dynamically generated
pages quickly.
&nbsp;
A nice introduction to PHP by Stig Sather Bakken can be found at
http://www.zend.com/zend/art/intro.php on the Zend website. Also, much  of the
PHP Conference Material is freely available.
&nbsp;
Session support in PHP consists of a way to preserve certain data across
subsequent accesses. This enables you to build more customized applications and
increase the appeal of your web site.
&nbsp;
A visitor accessing your web site is assigned a unique id, the so-called
session id. This is either stored in a cookie on the user side or is propagated
in the URL.
&nbsp;
session.save_path defines the argument which is passed to the save handler. If
you choose the default files handler, this is the path where the files are
created. Defaults to /tmp. See also session_save_path().
&nbsp;
There is an optional N argument to this directive that determines the number of
directory levels your session files will be spread around in. For example,
setting to &#039;5;/tmp&#039; may end up creating a session file and location like
/tmp/4/b/1/e/3/sess_4b1e384ad74619bd212e236e52a5a174If . In order to use N you
must create all of these directories before use. A small shell script exists in
ext/session to do this, it&#039;s called mod_files.sh. Also note that if N is used
and greater than 0 then automatic garbage collection will not be performed, see
a copy of php.ini for further information. Also, if you use N, be sure to
surround session.save_path in &quot;quotes&quot; because the separator (;) is also used
for comments in php.ini.
&nbsp;
- &#45;&#45;- 1. session.save_path safe mode and open basedir bypass &#45;&#45;-
session.save_path can be set in ini_set(), session_save_path() function. In
session.save_path there must be path where you will save yours tmp file. But
syntax for session.save_path can be:
&nbsp;
[/PATH]
&nbsp;
OR
&nbsp;
[N;/PATH]
&nbsp;
N - can be a string.
&nbsp;
EXAMPLES:
&nbsp;
1. session_save_path(&quot;/DIR/WHERE/YOU/HAVE/ACCESS&quot;)
2. session_save_path(&quot;5;/DIR/WHERE/YOU/HAVE/ACCESS&quot;)
&nbsp;
and
&nbsp;
3.
session_save_path(&quot;/DIR/WHERE/YOU/DONT/HAVE/ACCESS\0;/DIR/WHERE/YOU/HAVE/ACCESS&quot;)</pre>
</blockquote>
<pre>CACHE_LIMITER_FUNC(public)
{
        char buf[MAX_STR + 1];
        struct timeval tv;
        time_t now;
&nbsp;
        gettimeofday(&amp;tv, NULL);
        now = tv.tv_sec + PS(cache_expire) * 60;
#define EXPIRES &quot;Expires: &quot;
        memcpy(buf, EXPIRES, sizeof(EXPIRES) - 1);
        strcpy_gmt(buf + sizeof(EXPIRES) - 1, &amp;now);
        ADD_HEADER(buf);
&nbsp;
        snprintf(buf, sizeof(buf) , &quot;Cache-Control: public, max-age=%ld&quot;, PS(cache_expire) * 60); /* SAFE */
        ADD_HEADER(buf);
&nbsp;
        last_modified(TSRMLS_C);
}
&nbsp;
CACHE_LIMITER_FUNC(private_no_expire)
{
        char buf[MAX_STR + 1];
&nbsp;
        snprintf(buf, sizeof(buf), &quot;Cache-Control: private, max-age=%ld, pre-check=%ld&quot;, PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */
        ADD_HEADER(buf);
&nbsp;
        last_modified(TSRMLS_C);
}
&nbsp;
CACHE_LIMITER_FUNC(private)
{
        ADD_HEADER(&quot;Expires: Thu, 19 Nov 1981 08:52:00 GMT&quot;);
        CACHE_LIMITER(private_no_expire)(TSRMLS_C);
}
&nbsp;
CACHE_LIMITER_FUNC(nocache)
{
        ADD_HEADER(&quot;Expires: Thu, 19 Nov 1981 08:52:00 GMT&quot;);
        /* For HTTP/1.1 conforming clients and the rest (MSIE 5) */
        ADD_HEADER(&quot;Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0&quot;);
        /* For HTTP/1.0 conforming clients */
        ADD_HEADER(&quot;Pragma: no-cache&quot;);
}
&nbsp;
static php_session_cache_limiter_t php_session_cache_limiters[] = {
        CACHE_LIMITER_ENTRY(public)
        CACHE_LIMITER_ENTRY(private)
        CACHE_LIMITER_ENTRY(private_no_expire)
        CACHE_LIMITER_ENTRY(nocache)
        {0}
};
&nbsp;
static int php_session_cache_limiter(TSRMLS_D)
{
        php_session_cache_limiter_t *lim;
&nbsp;
        if (PS(cache_limiter)[0] == &#039;\0&#039;) return 0;
&nbsp;
        if (SG(headers_sent)) {
                char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
                int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
&nbsp;
                if (output_start_filename) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cache limiter - headers already sent (output started at %s:%d)&quot;,
                                output_start_filename, output_start_lineno);
                } else {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cache limiter - headers already sent&quot;);
                }
                return -2;
        }
&nbsp;
        for (lim = php_session_cache_limiters; lim-&gt;name; lim++) {
                if (!strcasecmp(lim-&gt;name, PS(cache_limiter))) {
                        lim-&gt;func(TSRMLS_C);
                        return 0;
                }
        }
&nbsp;
        return -1;
}</pre>
<pre>static void php_session_send_cookie(TSRMLS_D)
{
        smart_str ncookie = {0};
        char *date_fmt = NULL;
        char *e_session_name, *e_id;
&nbsp;
        if (SG(headers_sent)) {
                char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
                int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
&nbsp;
                if (output_start_filename) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cookie - headers already sent by (output started at %s:%d)&quot;,
                                output_start_filename, output_start_lineno);
                } else {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cookie - headers already sent&quot;);
                }
                return;
        }
&nbsp;
        /* URL encode session_name and id because they might be user supplied */
        e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)), NULL);
        e_id = php_url_encode(PS(id), strlen(PS(id)), NULL);
&nbsp;
        smart_str_appends(&amp;ncookie, COOKIE_SET_COOKIE);
        smart_str_appends(&amp;ncookie, e_session_name);
        smart_str_appendc(&amp;ncookie, &#039;=&#039;);
        smart_str_appends(&amp;ncookie, e_id);
&nbsp;
        efree(e_session_name);
        efree(e_id);
&nbsp;
        if (PS(cookie_lifetime) &gt; 0) {
                struct timeval tv;
                time_t t;
&nbsp;
                gettimeofday(&amp;tv, NULL);
                t = tv.tv_sec + PS(cookie_lifetime);
&nbsp;
                if (t &gt; 0) {
                        date_fmt = php_std_date(t TSRMLS_CC);
                        smart_str_appends(&amp;ncookie, COOKIE_EXPIRES);
                        smart_str_appends(&amp;ncookie, date_fmt);
                        efree(date_fmt);
                }
        }
&nbsp;
        if (PS(cookie_path)[0]) {
                smart_str_appends(&amp;ncookie, COOKIE_PATH);
                smart_str_appends(&amp;ncookie, PS(cookie_path));
        }
&nbsp;
        if (PS(cookie_domain)[0]) {
                smart_str_appends(&amp;ncookie, COOKIE_DOMAIN);
                smart_str_appends(&amp;ncookie, PS(cookie_domain));
        }
&nbsp;
        if (PS(cookie_secure)) {
                smart_str_appends(&amp;ncookie, COOKIE_SECURE);
        }
&nbsp;
        if (PS(cookie_httponly)) {
                smart_str_appends(&amp;ncookie, COOKIE_HTTPONLY);
        }
&nbsp;
        smart_str_0(&amp;ncookie);
&nbsp;
        /*      &#039;replace&#039; must be 0 here, else a previous Set-Cookie
                header, probably sent with setcookie() will be replaced! */
        sapi_add_header_ex(ncookie.c, ncookie.len, 0, 0 TSRMLS_CC);
}</pre>
<p><a href="http://www.askapache.com/php/php-session-hack.html"></a><a href="http://www.askapache.com/php/php-session-hack.html">PHP Session File Hacks</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/php/php-session-hack.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crazy POWERFUL Bash Prompt</title>
		<link>http://www.askapache.com/linux-unix/bash-power-prompt.html</link>
		<comments>http://www.askapache.com/linux-unix/bash-power-prompt.html#comments</comments>
		<pubDate>Tue, 25 May 2010 19:02:34 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Making Money]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[.bashrc]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bash_profile]]></category>
		<category><![CDATA[CommandLine]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Kung-Fu]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[PROMPT_COMMAND]]></category>
		<category><![CDATA[PS1]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell History]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Username]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4069</guid>
		<description><![CDATA[<p><a class="IFL" href='http://www.askapache.com/linux-unix/bash-power-prompt.html' title='bash power prompt PS1'><img width="350" height="65" src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1-350x65.png" class="attachment-thumbnail" alt="bash power prompt PS1" title="bash power prompt PS1" /></a>This <a href='http://www.askapache.com/linux-unix/bash-power-prompt.html' title='amazing bash linux prompt'>amazing bash linux prompt</a> does more than meets the eye.  If you want to know how to become really good with technology, linux is the secret sauce behind the AskApache articles.  Open Source is elixir of the web.  Thanks to everyone who helped me for the past 20 years.  <strong>I use linux/bsd</strong> because <strong>homey don't play</strong>, so this is geared to be as productive a prompt as I can make it.<br /><br /><strong>Don't have much time.. or just don't care?</strong> Not a problem, here are the 3 lines to copy and paste - you can just paste them right in your shell to test it, or add to a startup script.<br class="C" /></p>
<pre style='font-size:8px'>export AA_P=&#34;export PVE=\&#34;\\033[m\\033[38;5;2m\&#34;\$(( \`sed -n \&#34;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&#34; /proc/meminfo\` / 1024 ))\&#34;\\033[38;5;22m/\&#34;\$((\`sed -n \&#34;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&#34; /proc/meminfo\`/ 1024 ))MB\&#34;\\t\\033[m\\033[38;5;55m\$(&#60; /proc/loadavg)\\033[m\&#34;;echo -en \&#34;\&#34;&#34;
export PROMPT_COMMAND=&#34;history -a;((\$SECONDS % 10==0 ))&#38;&#38;eval \&#34;\$AA_P\&#34;;echo -en \&#34;\$PVE\&#34;;&#34;
export PS1=&#34;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &#34; &#38;&#38; eval $AA_P</pre>]]></description>
			<content:encoded><![CDATA[<p><a style="display:block;width:140px;float:left;padding:1em;" href='http://www.askapache.com/linux-unix/bash-power-prompt.html' title='bash power prompt screenshot'><img width="116" height="62" src="http://uploads.askapache.com/2010/03/bash-power-prompt-ss-116x62.png" class="attachment-thumbnail" alt="bash power prompt screenshot" title="bash power prompt screenshot" /></a>From <strong>setting the window title</strong> to show the last run command (filtered), saving your <strong>history</strong> and keeping multi-session history intact, resetting the <strong>color/cursor/highlighting</strong> of errant color-emitting commands, these 2 prompt examples do more than meet the eye and are extremely fast.</p>
<p>Don&#8217;t have much time or just don&#8217;t care? No problem, this is a simple copy and paste&#8230; here&#8217;s one to start (all 1 line, just cut and paste right into the shell, once you&#8217;ve made sure its safe).<br class="C" /></p>
<pre>PS1=&quot;\n\[\033[1;30m\][$$:$PPID - \j:\!\[\033[1;30m\]]\[\033[0;36m\] \T \
\[\033[1;30m\][\[\033[1;34m\]\u@\H\[\033[1;30m\]:\[\033[0;37m\]${SSH_TTY:-o} \
\[\033[0;32m\]+${SHLVL}\[\033[1;30m\]] \[\033[1;37m\]\w\[\033[0;37m\] \n\$ &quot;</pre>
<p><a href='http://www.askapache.com/linux-unix/bash-power-prompt.html/toprc/' rel='attachment wp-att-4414'>toprc</a></p>
<p>Or for POWER PROMPT</p>
<pre>PROMPT_COMMAND=&#039;history -a;echo -en &quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/1024))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip&quot; /proc/meminfo`/1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;&#039;
PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
 </pre>
<h2>Or for Extreme Power Prompt</h2>
<p>Updated!  5/25/2010,  This is what I use at the moment.. It&#8217;s the coolest code I&#8217;ve ever seen to do this.  I rewrote the above (and below) bash prompts to this format because it is much more robust, and believe it or not its way faster for your machine.  Yes the code below is correct, it looks a little weird to export vars from within an exported var statement..  but this is correct. If you just learn this one bit of code, you will gain a lot of shell kung fu, at least I have!  Enjoy!</p>
<pre style='font-size:9px'>export AA_P=&quot;export PVE=\&quot;\\033[m\\033[38;5;2m\&quot;\$(( \`sed -n \&quot;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\` / 1024 ))\&quot;\\033[38;5;22m/\&quot;\$((\`sed -n \&quot;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\`/ 1024 ))MB\&quot;\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\&quot;;echo -en \&quot;\&quot;&quot;
export PROMPT_COMMAND=&quot;history -a;((\$SECONDS % 10==0 ))&amp;&amp;eval \&quot;\$AA_P\&quot;;echo -en \&quot;\$PVE\&quot;;&quot;
export PS1=&quot;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &quot;
export PVE=&quot;\\033[m\\033[38;5;2m813\\033[38;5;22m/1024MB\\t\\033[m\\033[38;5;55m0.25 0.22 0.18 1/66 26820\\033[m&quot; &amp;&amp; eval $AA_P</pre>
<pre>[24574:16122 0:344] 05:49:07 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:344)$ export AA_P=&quot;export PVE=\&quot;\\033[m\\033[38;5;2m\&quot;\$(( \`sed -n \&quot;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\` / 1024 ))\&quot;\\033[38;5;22m/\&quot;\$((\`sed -n \&quot;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\`/ 1024 ))MB\&quot;\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\&quot;;echo -en \&quot;\&quot;&quot;
&gt;&gt;&gt; export &#039;AA_P=export PVE=&quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo` / 1024 ))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/ 1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;;echo -en &quot;&quot;&#039;
&gt;&gt;&gt; AA_P=&#039;export PVE=&quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo` / 1024 ))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/ 1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;;echo -en &quot;&quot;&#039;</pre>
<pre>[24574:16122 0:345] 05:49:09 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:345)$ export PROMPT_COMMAND=&quot;history -a;((\$SECONDS % 10==0 ))&amp;&amp;eval \&quot;\$AA_P\&quot;;echo -en \&quot;\$PVE\&quot;;&quot;
&gt;&gt;&gt; export &#039;PROMPT_COMMAND=history -a;(($SECONDS % 10==0 ))&amp;&amp;eval &quot;$AA_P&quot;;echo -en &quot;$PVE&quot;;&#039;
&gt;&gt;&gt; PROMPT_COMMAND=&#039;history -a;(($SECONDS % 10==0 ))&amp;&amp;eval &quot;$AA_P&quot;;echo -en &quot;$PVE&quot;;&#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 66 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.35 0.24 0.19 1/68 27241\033[m&#039;</pre>
<pre>813/1024MB      0.35 0.24 0.19 1/68 27241
[24574:16122 0:346] 05:49:09 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:346)$ export PS1=&quot;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &quot;
&gt;&gt;&gt; export &#039;PS1=\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
&gt;&gt;&gt; PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 67 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.35 0.24 0.19 1/68 27241\033[m&#039;</pre>
<pre>813/1024MB      0.35 0.24 0.19 1/68 27241
[24574:16122 0:347] 05:49:10 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:347)$ export PVE=&quot;\\033[m\\033[38;5;2m813\\033[38;5;22m/1024MB\\t\\033[m\\033[38;5;55m0.25 0.22 0.18 1/66 26820\\033[m&quot;
&gt;&gt;&gt; export &#039;PVE=\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;
&gt;&gt;&gt; PVE=&#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 67 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;</pre>
<h2>256 Color Prompt Command</h2>
<p class="bnote"><strong>NOTE:</strong> I have been preparing a 256color terminal article for some time now, as I have tweaked, hacked, read, and experimented with more than I would ever like to admit.  So stay tuned, there isn't any tutorial, book, or online howto remotely close to as good as what I'm close to posting...</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html/super-optimized-256color-prompt/" rel="attachment wp-att-4297"><img src="http://uploads.askapache.com/2010/03/super-optimized-256color-prompt.png" alt="Super-optimized 256color BASH Prompt" title="Super-optimized 256color BASH Prompt" width="726" height="177" class="size-full wp-image-4297" /></a></p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html/256-color-prompt/" rel="attachment wp-att-4280"><img src="http://uploads.askapache.com/2010/03/256-color-prompt.png" alt="256 color prompt_command and PS1" title="256 color prompt" width="642" height="147" class="size-full wp-image-4280" /></a></p>
<p>If you have a 256-color enabled terminal try this..<br class="C" /></p>
<pre>    export PROMPT_COMMAND=&#039;echo -en &quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/1024))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip&quot; /proc/meminfo`/1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;&#039;
    export PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;</pre>
<p>Which double-quoted is:</p>
<pre>declare -x PROMPT_COMMAND=&quot;echo -en \&quot;\\033[m\\033[38;5;2m\&quot;\$(( \`sed -n \&quot;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\`/1024))\&quot;\\033[38;5;22m/\&quot;\$((\`sed -n \&quot;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/Ip\&quot; /proc/meminfo\`/1024 ))MB\&quot;\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\&quot;&quot;
declare -x PS1=&quot;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &quot;</pre>
<p class="cnote"><strong>For Commandlinefu.com users</strong>:  Here ya go!  <a href='http://www.askapache.com/linux-unix/bash-power-prompt.html/toprc/' rel='attachment wp-att-4414'>toprc</a></p>
<p>That looks great, and is practicallly totally free in terms of how much cpu/work it makes the shell do for each command.  So for slow terminals, or text-terminals like I use, this is great.  Other than PS1, there is 1 other variable..  It&#8217;s called PROMPT_COMMAND and is execed right in front of the PS1.  I show 2 ways to utilize this, the goal being to show there is no right way.. fast is fast and money is money.  I use a function called aa_pc I threw together that shows me in color how much memory is on my system.. very cool.</p>
<h2>PROMPT = ?</h2>
<p>Here&#8217;s a screenshot of the code in my vim + screen multiplexed bash 4 environment..   It&#8217;s placed all the way at the bottom of the file and is the last thing executed by the client processing the script.  Also, while it&#8217;s great to look so good, this is all 100% for efficiency since I use one shell or another every day.</p>
<div id="attachment_4177" class="wp-caption alignnone" style="width: 805px"><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html/bash-prompt-screenshot/" rel="attachment wp-att-4177"><img src="http://uploads.askapache.com/2010/03/bash-prompt-screenshot.png" alt="Custom Power Prompt - currently mine" title="Custom Power Prompt -<br />
currently mine" width="795" height="596" class="size-full wp-image-4177" /></a><p class="wp-caption-text">Custom Power Prompt - currently mine</p></div>
<p>Here&#8217;s the code I&#8217;m using today, that produced this screen-shot &#8212; I am always changing stuff so it&#8217;s a little more tough to figure out.</p>
<pre>  function aa_pc()
  {
        local M=$( free -olm|sed &quot;/Mem/!d; s/Mem:[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\).*/ \
        ${GREP_COLOR}\2MB${R}\/\3MB/&quot;; ); echo -e &quot;$M `pwd`&quot;
  }
&nbsp;
  aa_grep_color(){ export GREP_COLOR=`tput setaf $(aa_random_under 6)`; }
  aa_random_under(){ echo -en $(( $RANDOM % ${1:-$RANDOM} + 1 )); }
  uptime1(){ sed &#039;/.*,  \([0-9]*\) users,  load average: \(.*\)/!d; s//[ \2, \1 users ]/;q&#039;;
&nbsp;
  $SED -n &#039;/i/!Q2&#039; &lt;&lt;&lt; $- &amp;&amp; \
  {
        case ${TERM:-dummy} in xterm*|screen*|*color*)echo; ;; *) return; esac;
  }
&nbsp;
  # hack for being able to source all the functions in this file from a script
  MASTER_RESET=$`echo -e &quot;rs1\nrs2\ninitc\nis2\ncnorm\nrmso\nsgr0&quot; | tput -S`
&nbsp;
  # only for color-aware (some guessing) terminals, kick everyone else OUT
  case ${TERM:-dummy} in xterm*|screen*|*color*)echo; ;; *) return; esac;
&nbsp;
  [[ -r /etc/DIR_COLORS ]] &amp;&amp; eval `dircolors -b /etc/DIR_COLORS`
&nbsp;
  # changes the window title in terminals like putty or konsole
  echo -ne &quot;\033]0; ${USER}@${HOSTNAME}  +${SHLVL} @${SSH_TTY/\/dev\/} - `uptime1` \007&quot;
&nbsp;
  # show title, setup the colors, vars, funcs, settings
  asetup_colors &amp;&amp; ascript_title
  export PROMPT_COMMAND=&#039;history -a;aa_pc&#039;
  export PS1=&#039;\[\033[1;30m\][$$:$PPID - \j:\!\[\033[1;30m\]]\[\033[0;36m\] \T\
  \d \[\033[1;30m\][\[\033[1;34m\]\u@\H\[\033[1;30m\]:\[\033[0;37m\]${SSH_TTY} \
  \[\033[0;32m\]+${SHLVL}\[\033[1;30m\]] \[\033[1;37m\]\w\[\033[0;37m\] \n\$ &#039;</pre>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ss.png" alt="bash power prompt screenshot" title="bash power prompt screenshot" width="898" height="480" /></a></p>
<p>I&#8217;ve used many shells over the years and have learned many tweaks and tricks for a powerful prompt.  It may look deceptively simple.  One cool thing this prompt does is display the command line (filtered) in the putty/konsole/xterm window, so if you have several windows minimized you can easily find the one you are looking for.<br class="C" /></p>
<p>There is a lot of good info about the BASH prompt around the net, but it can be complicated for a new user, and as an advanced user you will notice most of the info is very outdated and not very optimized for speed.  To get this articles recommended prompt working is devastatingly simple, just export the <code>PROMPT_COMMAND</code> and <code>PS1</code> variables that are shown below.  Most &#8220;power prompts&#8221; that utilize things like PROMPT_COMMAND do so very haphazardly or very extravagantly.</p>
<p>I&#8217;ve been called a lot of things but not extravagant, and because I use this prompt on many different servers, platforms, and systems I made sure to not make things complicated.  To test them just copy and paste the code below into your shell which will <strong>export PROMPT_COMMAND</strong> and <strong>PS1</strong> variables and work right away.  So test it out, and if you like it add it to your .bashrc or other startup file (please do a <code>$ man bash</code>).</p>
<ul>
<li><a href="#power-prompt-commands" rel="nofollow" >Custom Power Prompt Commands</a>
<ol>
<li><a href="#prompt_command" rel="nofollow" >PROMPT_COMMAND Detailed</a></li>
<li><a href="#detailed-ps1" rel="nofollow" >PS1 Detailed</a></li>
</ol>
</li>
<li><a href="#hacker-prompts" rel="nofollow" >Additional Info for Hackers</a>
<ol>
<li><a href="#set-xterm-title" rel="nofollow" >Setting Window Title</a></li>
<li><a href="#strip-colors" rel="nofollow" >Stripping Colors from PS1</a></li>
<li><a href="#uptime-alt" rel="nofollow" >Alternative to Uptime/Loadavg (proc)</a></li>
<li><a href="#multi-prompt-switcher" rel="nofollow" >Multi-Prompt Switcher Function</a></li>
</ol>
</li>
<li><a href="#bash-prompt-reading" rel="nofollow" >Bash Prompts &#8211; More Reading</a>
<ol>
<li><a href="#ps1-examples" rel="nofollow" >Other Simple Power Prompt Examples</a></li>
<li><a href="#bash-prompt-vars" rel="nofollow" >All Prompt Variables</a></li>
<li><a href="#prompt-escapes" rel="nofollow" >Escape Codes for PS1</a></li>
<li><a href="#more-reading" rel="nofollow" >Additional Reading</a></li>
</ol>
</li>
</ul>
<p><a id="power-prompt-commands" name="power-prompt-commands"></a></p>
<h2>Bash Power Prompt</h2>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1.png" alt="bash power prompt PS1" title="bash power prompt PS1" width="513" height="96" /></a><br />From setting the window title to show the last run command (filtered), saving your history and keeping multi-session history intact, resetting the color/cursor/highlighting of errant color-emitting commands, this prompt does more than meets the eye extremely fast.</p>
<p class="enote">Don&#8217;t have much time? Don&#8217;t care?  You may copy and paste these 2 lines into your shell and that&#8217;s all there is to it!</p>
<pre>export PROMPT_COMMAND=&#039;export H1=&quot;`history 1|sed -e &quot;s/^[\ 0-9]*//; s/[\d0\d31\d34\d39\d96\d127]*//g; s/\(.\{1,50\}\).*$/\1/g&quot;`&quot;;history -a;echo -e &quot;sgr0\ncnorm\nrmso&quot;|tput -S&#039;
export PS1=&#039;\n\e[1;30m[\j:\!\e[1;30m]\e[0;36m \T \d \e[1;30m[\e[1;34m\u@\H\e[1;30m:\e[0;37m`tty 2&gt;/dev/null` \e[0;32m+${SHLVL}\e[1;30m] \e[1;37m\w\e[0;37m\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;</pre>
<p><a id="prompt_command" name="prompt_command"></a></p>
<h2>PROMPT_COMMAND</h2>
<p>This holds commands to be run prior to displaying the prompt.  Let&#8217;s break it down.</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/askapache-prompt.jpg" alt="PS1 Prompt Example" title="PS1 Prompt Example" width="663" height="120" class="size-full wp-image-4150" /></a></p>
<p>First this takes the last command executed and filters it using sed to remove the initial history command number, and also to remove any quotes (single or double) and/or backticks.  Also, it only saves the first 50 chars, which are then exported as the value of H1, which because it is exported is now globally accessible to the rest of the shell.  This is important because we use this variable in PS1 to print the last run command as the title of our putty window (or konsole).</p>
<pre>export H1=`history 1 | sed -e &#039;s/^[\ 0-9]*//; s/[\d0\d31\d34\d39\d96\d127]*//g; s/\(.\{1,50\}\).*$/\1/g&#039;`</pre>
<p>The next command simply appends your last command to the history file.  Usually this is <code>~/.bash_profile</code>, or whatever <code>$HISTFILE</code> is.  This makes sure you never lose history in case of a shell crash or ssh connection terminated. </p>
<pre>history -a</pre>
<p>Finally there is this golden nugget of shell kung-fu.  This outputs 3 terminal escape sequences according to the terminal in use and its capabilities.. so very robust, should work on any shell newer than 1984.  By echoing the following 3 term names separated by a newline <code>\n</code> and using tput -S it will output the terminal sequences for all 3.  sgr0 resets the colors, cnorm resets the cursor, and rmso resets the background color.</p>
<p class="cnote">You can view the escape sequences generated by tput with strace, cat -t, etc..  For instance on my shell (xterm-256color via portaputty) the below command generates: <code>\33(B\33[m\33[?12l\33[?25h\33[27m</code>.  This is helpful because if you aren't coding for several terminals you can hard code that in your echo's instead of using tput, saving some overhead.</p>
<pre>echo -e &#039;sgr0\ncnorm\nrmso&#039; | tput -S
# For my term this is the same as if I just did
# echo -e &quot;\33(B\33[m\33[?12l\33[?25h\33[27m&quot;</pre>
<p><a id="detailed-ps1" name="detailed-ps1"></a></p>
<h2>PS1 Detailed</h2>
<p><code>PS1</code> is the variable that is expanded as your prompt.  So if you did a <code>$ unset PS1</code> then you can still run commands and everything, but your screen will be blank which is confusing to say the least.</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/askapache-htop.jpg" alt="The HTOP command in full color to manage mysql" title="The HTOP command in full color to manage mysql" width="404" height="176" class="size-full wp-image-4149" /></a></p>
<p>This PS1 shows which SHLVL level the shell is in, which is how many levels deep of shells you are currently at.  If you run <code>$ bash -l</code> from a bash shell it will create a new instance of bash as a child of the calling bash, so the SHLVL (shell level) gets incremented by 1.  I usually avoid creating subshells by instead executing a new bash with <code>exec</code> which instead of creating a new bash as a child of the current bash, it replaces the current bash process with the new one: <code>$ exec bash -l</code>.</p>
<pre>export PS1=&#039;\n\e[1;30m[\j:\!\e[1;30m]\e[0;36m \T \d \e[1;30m[\e[1;34m\u@\H\e[1;30m:\e[0;37m`tty 2&gt;/dev/null` \e[0;32m+${SHLVL}\e[1;30m] \e[1;37m\w\e[0;37m\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;
&nbsp;
# with nocolors
# export PS1=&#039;\n[\j:\!] \T \d [\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;</pre>
<h3>TTY</h3>
<p>This command is very useful for me because I use multiplexed terminals, about 6 at a time, so it is crucial sometimes to know which tty I am using.  Since SSH is the ONLY protocol I ever use for anything, I used to depend on the SSH_TTY variable being set instead of using tty, which as a command has more overhead then just echoing a variable.  But I found that when running multiplexing terminals with tmux, screen, etc.. the SSH_TTY variable stays with the initial tty created upon login.   <strong>Note:</strong> <code>2>/dev/null</code> redirects any errors that running the tty command might issue to the /dev/null device, which is the same thing as a black hole, it goes nowhere so is an efficient way to send data for deletion.  Depending on your server and ssh settings you may not even have a tty or it may just appear that you do not.  Some web hosting companies do odd things to prevent their users from using tty devices and programs.  But if you get a little creative you can always find the current tty.. like <code>$ readlink /proc/self/fd/0</code> will return the same thing as <code>$ tty</code>.</p>
<pre>`tty 2&gt;/dev/null`</pre>
<p><a id="set-xterm-title" name="set-xterm-title"></a></p>
<h3>Changing Window Title with PS1</h3>
<p>This simple bash function changes the title of the window to the passed parameter.  The key thing to note is that this works because of the special escapes on either end of the echo'd data.</p>
<pre>function set_window_title()
{
  echo -e &quot;\033]0; ${1:-$USER@$HOST - $SHLVL} \007&quot;;
}</pre>
<p><a id="hacker-prompts" name="hacker-prompts"></a></p>
<h2>Additional Info for Hackers</h2>
<p>More reading and digging.</p>
<p><a id="strip-colors" name="strip-colors"></a></p>
<h3>Strip Colors for Readability</h3>
<p>You can use this command to strip a PS1 of all colors, which shortens the variable dramatically in some cases.</p>
<pre>sed &#039;s/\\[eE][[0-9]*;[0-9]*m//g&#039; &lt;&lt;&lt; $PS1
# ie export PS1=$(sed &#039;s/\\[eE][[0-9]*;[0-9]*m//g&#039; &lt;&lt;&lt; $PS1);</pre>
<p><a id="multi-prompt-switcher" name="multi-prompt-switcher"></a></p>
<h3>Multi-Prompt Switcher Function</h3>
<p>This function demonstrates 1 way that you can change your prompts at will.  It creates an array named AAPS that you can add as many PS1 values to as you want.  Each time the function is run it simply changes the prompt string variable PS1 to the value of the next item in the AAPS array.  Once it reaches the last item in AAPS, it resets back to the first <code>AAPS[0]</code> prompt.  Just an example to play with, not tested very much.</p>
<pre>aa_multi_prompt ()
{
    declare -a AAPS;
    AAPS[0]=&#039;\n[\j:\!] \T \d [\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$&#039;;
    AAPS[1]=&#039;\n[\j:\!] \T \d \n[\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$&#039;;
&nbsp;
    : ${PLVL:=0};
    [[ &quot;${#AAPS[@]}&quot; -lt &quot;$PLVL&quot; || &quot;${#AAPS[@]}&quot; -eq &quot;$PLVL&quot; ]] &amp;&amp; PLVL=0;
    export PS1=${AAPS[$PLVL]} &amp;&amp; (( PLVL++ )) &amp;&amp; export PLVL
}</pre>
<h3>BASH 4 Multi-Prompt</h3>
<p>Here's an example from bash-4, but it works for all bash versions.</p>
<pre>prompt ()
{
    case &quot;$1&quot; in
        d)
            PS1=&#039;$(dirs) \$ &#039;
        ;;
        n)
            PS1=&#039;\$ &#039;
        ;;
        hsw)
            PS1=&#039;\h[$SHLVL]: \w \$ &#039;
        ;;
        hw)
            PS1=&#039;\h: \w \$ &#039;
        ;;
        sh)
            PS1=&#039;[$SHLVL] \h\$ &#039;
        ;;
        sw)
            PS1=&#039;[$SHLVL] \w \$ &#039;
        ;;
        uh)
            PS1=&#039;\u@\h\$ &#039;
        ;;
        uhsHw)
            PS1=&#039;\u@\h[$SHLVL]:\#: \w \$ &#039;
        ;;
        uhsw)
            PS1=&#039;\u@\h[$SHLVL]: \w \$ &#039;
        ;;
        uhw)
            PS1=&#039;\u@\h: \w \$ &#039;
        ;;
        uw)
            PS1=&#039;(\u) \w \$ &#039;
        ;;
        w)
            PS1=&#039;\w \$ &#039;
        ;;
    esac
}</pre>
<p><a id="uptime-alt" name="uptime-alt"></a></p>
<h3>Alternative to uptime:</h3>
<pre>echo &quot;Up for $(( $(sed &#039;s/^\([0-9]*\).*/\1/&#039; /proc/uptime) / (60*60*24) )) days - [`cat /proc/loadavg`]&quot;
# or
echo &quot;Uptime: $(( `sed &#039;s/^\([0-9]*\).*/\1/g&#039; /proc/uptime` / 86400 )) days. Load: $(&lt;/proc/loadavg)&quot;</pre>
<p><a id="bash-prompt-reading" name="bash-prompt-reading"></a></p>
<h2>Bash Prompts - More Reading</h2>
<p><a id="bash-prompt-vars" name="bash-prompt-vars"></a></p>
<h3>All Bash Prompt Variables</h3>
<p>These are the environment variables provided by BASH (and most shells) and control your prompt string.   While all are interesting and good to know about, <code>PROMPT_COMMAND</code> and <code>PS1</code> are the only ones that directly modify the prompt that is displayed.</p>
<dl>
<dt>PROMPT_COMMAND</dt>
<dl>If set, the value is executed as a command <strong>prior</strong> to issuing each primary prompt.</dl>
<dt>PS1</dt>
<dl>The value of this parameter is expanded and used as the primary prompt string.  The default value is "<code>\s-\v\$ </code>".</dl>
<dt>PS2</dt>
<dl>The value of this parameter is expanded as with PS1 and used as the secondary prompt string.  The default is "<code>> </code>".</dl>
<dt>PS3</dt>
<dl>The value of this parameter is used as the prompt for the select command.</dl>
<dt>PS4</dt>
<dl>The  value of this parameter is expanded as with PS1 and the value is printed before each command bash displays during an execution trace.  The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection.  The default is "<code>+</code>".</dl>
</dl>
<p><a id="prompt-escapes" name="prompt-escapes"></a></p>
<h3>Prompt Escape Codes</h3>
<p>When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command and the secondary prompt PS2 when it needs more input to complete a command.  Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:</p>
<ul>
<li><code>\a</code> - an ASCII bell character (07)</li>
<li><code>\d</code> - the date in "Weekday Month Date" format (e.g., "Tue May 26")</li>
<li><code>\D{format}</code> - the format is passed to <a href="http://www.freebsd.org/cgi/man.cgi?query=strftime" rel="nofollow" >strftime(3)</a> and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required
<li><code>\e</code> - an ASCII escape character (033)</li>
<li><code>\h</code> - the hostname up to the first '.'</li>
<li><code>\H</code> - the hostname</li>
<li><code>\j</code> - the number of jobs currently managed by the shell</li>
<li><code>\l</code> - the basename of the shellâs terminal device name</li>
<li><code>\n</code> - newline</li>
<li><code>\r</code> - carriage return</li>
<li><code>\s</code> - the name of the shell, the basename of <var>$0</var> (the portion following the final slash)</li>
<li><code>\t</code> - the current time in 24-hour HH:MM:SS format</li>
<li><code>\T</code> - the current time in 12-hour HH:MM:SS format</li>
<li><code>\@</code> - the current time in 12-hour am/pm format</li>
<li><code>\A</code> - the current time in 24-hour HH:MM format</li>
<li><code>\u</code> - the username of the current user</li>
<li><code>\v</code> - the version of bash (e.g., 2.00)</li>
<li><code>\V</code> - the release of bash, version + patch level (e.g., 2.00.0)</li>
<li><code>\w</code> - the current working directory, with <var>$HOME</var> abbreviated with a tilde</li>
<li><code>\W</code> - the basename of the current working directory, with <var>$HOME</var> abbreviated with a tilde</li>
<li><code>\!</code> - the history number of this command</li>
<li><code>\#</code> - the command number of this command</li>
<li><code>\$</code> - if the effective UID is 0, a <strong>#</strong>, otherwise a <strong>$</strong></li>
<li><code>\nnn</code> - the character corresponding to the octal number nnn
<li><code>\\</code> - a backslash</li>
<li><code>\[</code> - begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt</li>
<li><code>\]</code> - end a sequence of non-printing characters</li>
</ul>
<p>The  command  number  and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file, while the command number is the position in the sequence of commands executed during the current shell session.  After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject to the value of the promptvars shell option, which if set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described in PROMPTING above.   <var>promptvars</var> is enabled by default.</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1.png" alt="bash power prompt PS1" title="bash power prompt PS1" width="513" height="96" /></a></p>
<p><a id="ps1-examples" name="ps1-examples"></a></p>
<h3>More Example Prompts</h3>
<pre>export PS1=&quot;\n\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]\n$ \e[0m&quot;
[user@host][~/bin/tools]
$</pre>
<pre>export PS1=&quot;\n[$?]\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]($SHLVL:\!)\n\[\033[0m\]\$ &quot;
[0][user@host][~/bin/tools](1:2130)</pre>
<pre>export PS1=&#039;\[\033[1;33m\]\u\[\033[1;37m\]@\[\033[1;32m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]&#039;
user@host:~/bin/tools $</pre>
<pre>export PS1=&quot;\e[1;31m[\h]$NC \W &gt; \[\033]0;\${TERM} [\u@\h] \w\]&quot;
[lifesaver] tools &gt;</pre>
<h2>Benchmarking PROMPT_COMMAND</h2>
<p>When figuring out how resource intensive your prompt_command is (if you choose to do that sort of thing), it's nice to do it like this.  I ended up using  this information from the following test to create the prompt_command used in the first 256-color prompt above.</p>
<pre>#!/bin/bash
&nbsp;
function clean_results()
{
      grep ^real | cut -dm -f2 | sort | uniq -c | sort -n
}
&nbsp;
for i in {0..500};
do
      time sh -c &quot;expr `sed -nu &#039;s/^MemFree:[\t ]\+\([0-9]\+\) kB/\1/Ip&#039; /proc/meminfo`/1024&quot; &amp;&gt;/dev/nulll;
done 2&gt;&amp;1 | clean_results
&nbsp;
# print separating line
printf &quot;%$((${COLUMNS:-`tput cols`} - 10))s\n&quot; &#039; &#039; | sed -u &#039;s/ /-/g&#039;
&nbsp;
for i in {0..500};
do
      time sh -c &quot;echo $(( `sed -nu &#039;s/^MemFree:[\t ]\+\([0-9]\+\) kB/\1/Ip&#039; /proc/meminfo`/1024 ))&quot; &amp;&gt;/dev/null;
done 2&gt;&amp;1 | clean_results
&nbsp;
exit $?</pre>
<p>Generates this output, meaning that using expr takes longer.</p>
<pre>      1 0.011s
      1 0.014s
      2 0.009s
      2 0.012s
      5 0.008s
     12 0.004s
     47 0.007s
    215 0.005s
    216 0.006s
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-
      1 0.003s
      2 0.007s
     59 0.006s
    196 0.004s
    243 0.005s</pre>
<p><a id="more-reading" name="more-reading"></a></p>
<h3>Additional Links</h3>
<ul>
<li><a href="http://tldp.org/HOWTO/From-PowerUp-To-Bash-Prompt-HOWTO.html" rel="nofollow" >From Power Up To Bash Prompt - TLDP</a></li>
<li><a href="http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Bash-Prompt-HOWTO.html" rel="nofollow" >Bash Prompt HOWTO -TLDP</a></li>
<li><a href="http://tldp.org/LDP/abs/html/sample-bashrc.html" rel="nofollow" >A Sample .bashrc File - TLDP</a></li>
<li><a href="http://gentoo.linuxhowtos.org/bash/bash_prompt_howto.htm" rel="nofollow" >Gentoo Linux Howtos: bash -> Bash Prompt Howto - Gentoo</a></li>
<li><a href="http://www.debian-administration.org/article/Fancy_Bash_Prompts" rel="nofollow" >Fancy Bash Prompts - Debian Administration</a></li>
</ul>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"></a><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html">Crazy POWERFUL Bash Prompt</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux-unix/bash-power-prompt.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>HOWTO: Uninstall CPANEL over SSH</title>
		<link>http://www.askapache.com/server-administration/uninstall-cpanel.html</link>
		<comments>http://www.askapache.com/server-administration/uninstall-cpanel.html#comments</comments>
		<pubDate>Sat, 24 Apr 2010 18:55:40 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[cpanel uninstall]]></category>
		<category><![CDATA[kill cpanel]]></category>
		<category><![CDATA[linux find]]></category>
		<category><![CDATA[uninstall cpanel]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4404</guid>
		<description><![CDATA[<p>The following is just a quick reference of some of the commands I used to uninstall cpanel.  This is for advanced users of the shell.  If you aren't that advanced and you run a single one of these commands without fully understanding it, you will probably kill your server, probably lose everything on it permanently, probably not have a website or email for weeks..  So backup all your data FIRST.  Also, if you aren't 100% sure you won't run into problems, you should contact your hosts technical support - but be prepared for some MAJOR negativity..  cpanel makes things very easy for hosts, and the last thing tech support wants is to fix a server broken by someone who doesn't know what they are doing.</p>]]></description>
			<content:encoded><![CDATA[<p><strong>WARNING!</strong> This is for advanced users of the shell, this is NOT a howto or tutorial.  The thing is, I googled <strong>how to uninstall cpanel</strong> and for once in my life I came up empty.. And certainly the cpanel official sites themselves don&#8217;t provide any instructions other than to say &#8220;Dont uninstall it, reinstall your entire operating system without it.&#8221;..   they sure don&#8217;t seem confident that they know exactly what their code is doing.  At this point this is more of a series of notes than a guide.  Ok now go have some fun!</p>
<h2>Why Uninstall?</h2>
<p>Why?  Because I have always built my servers, php installations, perl installs, ruby, iptables, everything from source.  I read the INSTALL/README docs, I read the man pages, and I read the info pages as well.  I google for configuration advice, I google for tips, and I don&#8217;t need a web-based perl script messing my stuff up!</p>
<p>The main problems I had with cpanel, which really is a great bit of software for millions of website developers, is that it was incredibly sneaky!  I used it for about 6 months and spent that entire time trying to figure out what the heck it was doing.  A couple issues that I really disliked, it takes over your bind install, it takes over your apache install, it takes over your php install.  And although it does let you configure some things (very few) for custom configurations and the like, I just don&#8217;t need any of that.  By removing the darn thing I am saving GIGS of space on my server, tons of bandwidth, and most importantly to me I am saving CPU and processing time along with RAM and IO speed.</p>
<h3>Anything Else</h3>
<p>Please.. I could go on for DAYS!  Another reason I have wanted to be rid of cpanel is that I like my servers to be as lean and mean as possible.  This means I like as few files and processes as possible.  There are many benefits to this, like it&#8217;s much easier for my integrity checking software and rootkit/antivirus software to run and drastically reduces the false positives.  And there is that glaring security issue of constantly having cpanel run it&#8217;s own software to create the WHM/Cpanel web interface, which is accessible online.  I haven&#8217;t researched cpanel security at all, it&#8217;s possible that it never has security problems that are published, but for me, why take the chance?</p>
<h2>Warning &#8211; Caution!</h2>
<p>The following is just a quick reference of some of the commands I used to uninstall cpanel.  This is for advanced users of the shell.  If you aren&#8217;t that advanced and you run a single one of these commands without fully understanding it, you will probably kill your server, probably lose everything on it permanently, probably not have a website or email for weeks..  So backup all your data FIRST.  Also, if you aren&#8217;t 100% sure you won&#8217;t run into problems, you should contact your hosts technical support &#8211; but be prepared for some MAJOR negativity..  cpanel makes things very easy for hosts, and the last thing tech support wants is to fix a server broken by someone who doesn&#8217;t know what they are doing.</p>
<h2>Last Warning!</h2>
<p>Unless you understand what theses commands do and the purpose they serve, do not try any of this.  These are not the exact commands I used verbatim, they are also not in order.  I only put them up here because I was so amazed that google didn&#8217;t have any uninstall cpanel intructions.  Hopefully it&#8217;s not a conspiracy that will get my site taken down.. ;)</p>
<p>That said and out of the way, it really only took me about 10 minutes to uninstall cpanel completely.  But keep in mind I have been closely monitoring and debugging cpanel for 6 months, so I knew what I was doing.  And finally, I do apologize for not having better instructions.. but hey, if you don&#8217;t get this then you have no business trying to figure out how to uninstall cpanel!  It&#8217;s great software and shouldn&#8217;t be removed unless you are fully capable of managing email/dns/www/ftp and any/all other servers and services on your machine by hand.</p>
<h2>Do This First</h2>
<p>I have a few drafts I&#8217;m working on at the moment with specifics, but for now you will have to figure it out with google.  Basically you want to make sure you don&#8217;t totally knock your machine offline without being able to reconnect.  What I do is compile a static version of openssh and a few other security-type shell tools, and configure this binary sshd to run by using inittab, which is the file run by init (pid 1) and makes sure if it dies it is restarted.  Here is my /etc/inittab to run the static sshd binary:</p>
<pre>hh:12345:respawn:/failover/os/sbin/aassh -D -q -u0 -f /failover/os/etc/aassh</pre>
<p>Another trick is to keep a detached screen logged in to root.  That way if you mess up your sudoers or securetty or pam or whatever, you can just reattach and fix it.</p>
<p>Finally, you may want to setup your syslog to start earlier than usual, and set up more than normal verbosity.  ( I take it to the max ).  Then you should setup a 2nd server or machine somewhere to act as a syslog server.  Lastly, configure your web server syslog to copy all messages to the remote syslog you set up.  I use a reverse ssh tunnel to encrypt the syslog packets, but when I do something serious like reboot after uninstalling cpanel, I prepare for it by adding additional networking routes on my machine to make sure I will get some logs even if sshd cant start or even if my network addresses aren&#8217;t brought up correctly.</p>
<p>If that sounds easy to you, please continue.   If you are saying: Wha??? Continue in read-only mode.</p>
<p class="cnote">Also, you can&#8217;t just uninstall cpanel, I have replaced a lot of cpanel already, like building my own bind, apache, php, syslog and making sure they work and aren&#8217;t being tampered with by cpanel.  Basically cpanel runs everything on your server in most cases, so you should prepare by creating your own static software to replace cpanel, and make sure it works.</p>
<h2>Find files Accessing /var/cpanel</h2>
<p>More than likely these will need to be killed.</p>
<pre>lsof +w -Rg -nP +c15 -x f +D /var/cpanel
lsof +w -Rg -nP +c15 -x f +D /usr/local/cpanel</pre>
<h2>Killing cpanel</h2>
<p>Just an example, your machine may have a lot more than these, I have been slowly taking control of my machine back from cpanel for 6 months, so it was easier for me.</p>
<pre>for P in tailwatchd queueprocd cpanellogd exim; do pkill -9 $P; done</pre>
<h2>Commands and Shortcuts</h2>
<pre>alias NF=&#039;nice find $PWD -mount -depth ! -type d&#039;
alias NFF=&#039;nice find $PWD -mount -depth ! -type d | xargs -IF87 file F87&#039;
alias NA=&#039;nice find $PWD -mount -depth&#039;
alias NAF=&#039;nice find $PWD -mount -depth | xargs -IF87 file F87&#039;</pre>
<h2>Watch out for crontab</h2>
<p>An example of the sneakiness (from my POV, from most it&#8217;s called builtin robustness) that cpanel does is automagically adding crontab entries that make it behave similarly to a self-propagating virus.  If you don&#8217;t disable the cronjobs and kill the right processes within a short period of time, be prepared for a magic resurrection.</p>
<p>Here&#8217;s my awesome crontab information function, you will need to check every file, it lists the default crons on my box, and every users crontab, but it can&#8217;t account for other cron software like at and other crons.</p>
<pre>function askapache_crontab()
{
  local GG i;
  for i in `getent passwd|cut -d &quot;:&quot; -f1`;
  do
    GG=$(sudo crontab -u $i -l 2&gt;$N6 | tr -s &#039;\n\000&#039; | sed &#039;/^#/d&#039;);
    [[ ${#GG} -gt 3 ]] &amp;&amp; sleep 1 &amp;&amp; echo -e &quot;$i \n\n${GG}&quot;
  done;
   sleep 4;
   ls -aLls1ch &#45;-color=always /etc/cron.{hourly,daily,weekly,monthly,d} | sed &#039;/^total/d; /\ drwxr-xr-x/d&#039;;
}</pre>
<pre>grep -ir /var/spool cpan</pre>
<pre>#6 3 * * * /scripts/upcp
#0 1 * * * /scripts/cpbackup
#0 2 * * * /scripts/mailman_chown_archives
#35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check &amp;&amp; /usr/local/cpanel/bin/tail-check
#11,26,41,56 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue &gt; /dev/null 2&gt;&amp;1
#30 */4 * * * /usr/bin/test -x /scripts/update_db_cache &amp;&amp; /scripts/update_db_cache
#45 */8 * * * /usr/bin/test -x /usr/local/cpanel/bin/optimizefs &amp;&amp; /usr/local/cpanel/bin/optimizefs
#*/5 * * * * /usr/local/cpanel/bin/dcpumon &gt;/dev/null 2&gt;&amp;1
#25 1 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl &#45;-notify</pre>
<h2>Delete Crontabs</h2>
<pre>sudo crontab -u mailman -r</pre>
<h2>Find INIT scripts with cpanel</h2>
<p>This is the main startup script: <code>/usr/local/cpanel/etc/init/startup</code></p>
<p>I had no idea ruby-on-rails was being controlled by cpanel.. sneaky bugger.  You can tell by all of these advanced unix commands just how difficult it would be to uninstall cpanel, its totally like the Alien!</p>
<pre>(1:3744)# find . ! -type d -print0|xargs -0 -I&#039;F87&#039; grep -Hi &quot;cpan\|tailwat\|chkser&quot; F87
./fastmail:# Author:       cPanel, Inc. &lt;nick@cpanel.net&gt;
./httpd:        HTTPD=/usr/local/cpanel/bin/chroothttpd
./cpanel:# cpanel8       Start Cpanel Services
./cpanel:# Author:       cPanel, Inc. &lt;nick@cpanel.net&gt;
./cpanel:# description: This is the cpanel webserver and chat.
./cpanel:# processname: cpaneld
./cpanel:# pidfile: /var/run/cpanel.pid
./cpanel:[ -f /usr/local/cpanel/etc/init/startup ] || exit 0
./cpanel:       if [ -f &quot;/var/cpanel/smtpgidonlytweak&quot; ]; then
./cpanel:       echo -n &quot;Starting cPanel services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startcpsrvd
./cpanel:       echo -n &quot;Starting cPanel brute force detector services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startcphulkd
./cpanel:    echo -n &quot;Starting cPanel dav services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startcpdavd
./cpanel:               daemon /usr/local/cpanel/etc/init/startcppop
./cpanel:       echo -n &quot;Starting cPanel Chat services: &quot;
./cpanel:               daemon /usr/local/cpanel/entropychat/entropychat
./cpanel:               daemon /usr/local/cpanel/bin/startmelange
./cpanel:                       /usr/local/cpanel/bin/startinterchange
./cpanel:       echo -n &quot;Starting cPanel ssl services: &quot;
./cpanel:       daemon /usr/local/cpanel/startstunnel
./cpanel:    echo -n &quot;Starting cPanel Queue services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startqueueprocd
./cpanel:    echo -n &quot;Starting tailwatchd: &quot;
./cpanel:    daemon /usr/local/cpanel/libexec/tailwatchd &#45;-start
./cpanel:       echo -n &quot;Starting cPanel Log services: &quot;
./cpanel:       daemon /usr/local/cpanel/cpanellogd
./cpanel:    action &quot;Starting mailman services: &quot; /usr/local/cpanel/etc/init/startmailman
./cpanel:    action &quot;Stopping tailwatchd: &quot; /usr/local/cpanel/libexec/tailwatchd &#45;-stop
./cpanel:    action &quot;Stopping cPanel services: &quot; /usr/local/cpanel/etc/init/stopcpsrvd
./cpanel:       action &quot;Stopping cPanel dav services: &quot; /usr/local/cpanel/etc/init/stopcpdavd
./cpanel:       action &quot;Stopping cPanel queue services: &quot; /usr/local/cpanel/etc/init/stopqueueprocd
./cpanel:       action &quot;Stopping cPanel brute force detector services: &quot; /usr/local/cpanel/etc/init/stopcphulkd
./cpanel:               action &quot;Stopping pop3 services: &quot; /usr/local/cpanel/etc/init/stopcppop
./cpanel:       echo -n &quot;Stopping cPanel log services: &quot;
./cpanel:       killproc cpanellogd
./cpanel:       echo -n &quot;Stopping cPanel Chat services: &quot;
./cpanel:       action &quot;Stopping cPanel ssl services: &quot; /usr/local/cpanel/etc/init/stopstunnel
./cpanel:       action &quot;Stopping mailman services: &quot; /usr/local/cpanel/etc/init/stopmailman
./cpanel:       if [ -e &quot;/usr/local/cpanel/3rdparty/mailman/bin/mailmanctl&quot; ]; then
./exim:if [ -e &quot;/etc/chkserv.d&quot; ]; then
./exim:        for file in `ls /etc/chkserv.d`
./exim:            if [ ! -e &quot;/usr/local/cpanel/libexec/tailwatchd&quot; ]; then
./exim:    if [ -x &quot;/usr/local/cpanel/etc/init/startspamd&quot; ]; then
./exim:        /usr/local/cpanel/etc/init/startspamd
./exim:        if [ ! -e &quot;/usr/local/cpanel/libexec/tailwatchd&quot; ]; then
./ror:  /usr/local/cpanel/bin/rormgr &#45;-startboot
./ror:  /usr/local/cpanel/bin/rormgr &#45;-stopall
./ror:  /usr/local/cpanel/bin/rormgr &#45;-stopall
./ror:  /usr/local/cpanel/bin/rormgr &#45;-startboot
./ror:  /usr/local/cpanel/bin/rormgr &#45;-statusall
./securetmp:# Author:       cPanel, Inc. &lt;copyright@cpanel.net&gt;</pre>
<h3>Turn off cpanel services</h3>
<p>You should remove the below delete command and start by just disabling the inits by turning them off.  Then reboot. Then delete.  If your machine won&#8217;t reboot, I told you so, Cpanel told you so, and likely your host told you so.</p>
<pre>for S in cpanel ror securetmp fastmail exim; do R=$(command chkconfig &#45;-level 123456 $S off ||echo); R=$(command chkconfig &#45;-del $S ||echo); done</pre>
<h4>HTTPD</h4>
<p>If you are running chrooted httpd then you&#8217;ll need to make sure you don&#8217;t delete your entire webserver on accident.  Here&#8217;s a relevant part from the /etc/init.d/httpd script.</p>
<pre># the path to your httpd binary, including options if necessary
if [ -e &quot;/etc/chroothttpd&quot; ]; then
        HTTPD=/usr/local/cpanel/bin/chroothttpd
else
        HTTPD=/usr/local/apache/bin/httpd
fi</pre>
<h2>Finding files owned by cpanel</h2>
<p>Some super cool bash commands in this post.. let&#8217;s start with one to find all the files and folders on your machine owned by cpanel.  Check your /etc/passwd file for your machines specific usernames and groups.  This command saves all the filenames to ~/cpanel-files-backup.txt, which is used by tar next to create a backup of all of them.</p>
<pre>{ find / -mount -depth -maxdepth 150 \( -group cpanel -o   -group cpanel-phpmyadmin -o -group cpanel-phppgadmin   -o -group cpanelphpmyadmin   -o -group cpanelphppgadmin   -o -group cpanelhorde   -o -group cpanelroundcube \) -print; find / -mount -depth -maxdepth 150 \( -user cpanel -o   -user cpanel-phpmyadmin -o -user cpanel-phppgadmin   -o -user cpanelphpmyadmin   -o -user cpanelphppgadmin   -o -user cpanelhorde   -o -user cpanelroundcube \) -print; } &gt; ~/cpanel-files-backup.txt</pre>
<p>Here&#8217;s another way to search directories.</p>
<pre> grep &#45;-color=always -Hir cpanel /var</pre>
<h2>Create the Backup</h2>
<p>Note that you must have the latest version of tar for this exact command, also you should backup /var/cpanel and /usr/local/cpanel and /etc and heck the whole machine why dontcha!</p>
<pre>tar -T ~/cpanel-files-backup.txt -cvz &#45;-checkpoint=1000 &#45;-checkpoint-action=&quot;ttyout=\rHit %s checkpoint #%u&quot; -f /cpanel-files-backup.tgz &#45;-totals</pre>
<h2>Remove Files</h2>
<p>Once you do this your upstream without a paddle, you better make sure you know what you&#8217;re doing with this.  This removes all those files.</p>
<pre>cat ~/cpanel-files-backup.txt | xargs -I&#039;F87&#039; rm -vfr F87</pre>
<p>Additionally you will want to remove /usr/local/cpanel and /var/cpanel &#8211; What I always do when running as root is alias my rm command to instead simply move the files to a .trash folder.  That way if something goes bork you have a better chance at fixing it.</p>
<h2>Find Group-Owned Files</h2>
<pre>find / -mount -depth -maxdepth 150 \
\(  -group cpanel -o \
  -group cpanel-phpmyadmin \
  -o -group cpanel-phppgadmin \
  -o -group cpanelphpmyadmin \
  -o -group cpanelphppgadmin \
  -o -group mailman \
  -o -group cpanelhorde \
  -o -group cpanelroundcube \
\) -fprintf /root/cpanel-group-files.log &#039;%#8k %#5m %11M %#10u:%-10g %-5U:%-5G %p %f %Y %F\n&#039;</pre>
<h2>Find User-Owned Files</h2>
<pre>find / -mount -depth -maxdepth 150 \(
  -user cpanel \
  -o -user cpanel-phpmyadmin \
  -o -user cpanel-phppgadmin \
  -o -user cpanelphpmyadmin \
  -o -user cpanelphppgadmin \
  -o -user mailman \
  -o -user cpanelhorde \
  -o -user cpanelroundcube
\) -fprintf /root/cpanel-users-files.log &#039;%#8k %#5m %11M %#10u:%-10g %-5U:%-5G %p %f %Y %F\n&#039;</pre>
<pre>       4  0755  drwxr-xr-x     cpanel:cpanel     32002:32004 /var/cpanel/userhomes/cpanel cpanel d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/tmp tmp d reiserfs
       4  0644  -rw-r&#45;-r&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches caches d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel .cpanel d reiserfs
       4  0750  drwxr-x&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/mail mail d reiserfs
       4  0711  drwx&#45;-x&#45;-x cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin cpanel-phpmyadmin d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/sessions sessions d reiserfs
       4  0644  -rw-r&#45;-r&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches caches d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel .cpanel d reiserfs
       4  0750  drwxr-x&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/mail mail d reiserfs
       4  0711  drwx&#45;-x&#45;-x cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin cpanelphppgadmin d reiserfs
       4  0750  drwxr-x&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube/mail mail d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube/sessions sessions d reiserfs
       4  0711  drwx&#45;-x&#45;-x cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube cpanelroundcube d reiserfs
       4  0644  -rw-r&#45;-r&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches caches d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel .cpanel d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/roundcube/tmp tmp d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/roundcube/log log d reiserfs</pre>
<h3>Find Permissions</h3>
<pre>cat ~/cpanel-group-files.log ~/cpanel-users-files.log |tr -s &#039;\000 \t&#039;|cut -d&#039; &#039; -f3|sort -u</pre>
<h3>Find files tailwatchd</h3>
<pre>(1:3732)# $NICE find ${1:-`pwd`} -mount -name &#039;*tailwatch*&#039;
/usr/local/cpanel/libexec/tailwatchd
/usr/local/cpanel/libexec/tailwatch
/usr/local/cpanel/libexec/tailwatch/tailwatchd
/usr/local/cpanel/etc/init/scripts/freebsd/tailwatchd.sh
/usr/local/cpanel/etc/init/scripts/trustix/tailwatchd
/usr/local/cpanel/etc/init/scripts/centos/tailwatchd
/usr/local/cpanel/etc/init/scripts/suse/tailwatchd
/usr/local/cpanel/etc/init/scripts/caos/tailwatchd
/usr/local/cpanel/etc/init/scripts/whitebox/tailwatchd
/usr/local/cpanel/etc/init/scripts/mandrake/tailwatchd
/usr/local/cpanel/etc/init/scripts/debian/tailwatchd
/usr/local/cpanel/etc/init/scripts/redhat/tailwatchd
/usr/local/cpanel/etc/init/scripts/fedora/tailwatchd
/usr/local/cpanel/etc/init/stoptailwatchd
/usr/local/cpanel/etc/init/starttailwatchd
/usr/local/cpanel/bin/tailwatchd
/usr/local/cpanel/logs/tailwatchd_log
/var/log/cpanel/tailwatchd_log
/var/cpanel/log_rotation/cp_tailwatchd_log.cpanellogd
/var/cpanel/tailwatch.positions
/var/run/tailwatchd.pid
/etc/chkserv.d/tailwatchd
/scripts/restartsrv_tailwatchd</pre>
<h2>Delete cpanel Users/Groups</h2>
<pre>for U in cpanel-phpmyadmin cpanel-phppgadmin cpanelphpmyadmin cpanelphppgadmin cpanelhorde cpanelroundcube machbuild; do userdel -fr $U; groupdel $U; done</pre>
<h2>Check for broken symlinks</h2>
<pre>find / -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039;</pre>
<p>Especially check /etc</p>
<pre>$ find /etc -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039;
/etc/ftpd-rsa.pem                   broken symbolic link to `/var/cpanel/ssl/ftp/ftpd-rsa.pem&#039;
/etc/rc.d/rc1.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc1.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc1.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc3.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc3.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc3.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc6.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc6.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc6.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc5.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc5.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc5.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc2.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc2.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc2.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc4.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc4.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc4.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc0.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc0.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc0.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/authlib/authProg               broken symbolic link to `/usr/local/cpanel/bin/courier-auth&#039;</pre>
<p>And delete if you are sure</p>
<pre>find /etc -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039; |cut -d&#039; &#039; -f1|xargs -I&#039;F87&#039; rm -rvf &#039;F87&#039;</pre>
<h2>Reinstall CSF</h2>
<p>The only thing I actually used that came with cpanel is the CSF/LFD Firewall package, which is a fantastic piece of software.  I had to reinstall this, and to get it working without cpanel add the following line to the csf.conf</p>
<pre>GENERIC = &quot;1&quot;</pre>
<h2>Thats It</h2>
<p>Now once you&#8217;ve cleaned up everything, you should try everything conceivable to get an error before rebooting.  Like you should start and stop every service in /etc/init.d/, you should use telinit to check various runlevels (which keeps your sshd connection still live).  Go all out, should take at least a full hour.</p>
<p>Another thing I like to do is rebuild alot of my source-built software again in case anything got messed up.  I upgrade perl from cpanels 5.8.8 to 5.10, which is pretty thorough, and you know, reinstall anything else I think I might need.  One of the benefits of compiling your own software is all I have to do is cd to the source directory and type <code>make -B &#038;&#038; ( { make test || make check || make checks || make tests; } || echo  ) &#038;&#038; sudo make install</code> and that&#8217;s it.  The tests/checks are optional of course.</p>
<p>If anyone actually ever reads this and does it, please share your advice here.. everybody knows we need it!  Good Luck</p>
<p><a href="http://www.askapache.com/server-administration/uninstall-cpanel.html"></a><a href="http://www.askapache.com/server-administration/uninstall-cpanel.html">HOWTO: Uninstall CPANEL over SSH</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/server-administration/uninstall-cpanel.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real-Life Htaccess Files from My Server</title>
		<link>http://www.askapache.com/htaccess/real-world-htaccess-files.html</link>
		<comments>http://www.askapache.com/htaccess/real-world-htaccess-files.html#comments</comments>
		<pubDate>Sat, 17 Apr 2010 15:06:22 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[AddHandler]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Block IP]]></category>
		<category><![CDATA[Cache-Control]]></category>
		<category><![CDATA[cheatsheets]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[etag]]></category>
		<category><![CDATA[htaccess tricks]]></category>
		<category><![CDATA[http cookie]]></category>
		<category><![CDATA[indexes]]></category>
		<category><![CDATA[Mod_Security]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[password protection]]></category>
		<category><![CDATA[real world]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4357</guid>
		<description><![CDATA[<pre>#### No https except to wp-admin - 
# If the request is empty ( implies fopen or normal file access by a php script )
RewriteCond %{THE_REQUEST} ^$ [OR]
&#160;
# OR if the request if for wp-admin or wp-login.php
RewriteCond %{REQUEST_URI} ^/(wp-admin&#124;wp-login\.php).*$ [NC,OR]
&#160;
# OR if the Referer is https
RewriteCond %{HTTP_REFERER} ^https://www.askapache.com/.*$ [NC]
&#160;
# THEN skip the following rule, basically all this does is force https or badhost to be redirected
# BUT because of the above 3 rewritecond&#039;s, this won&#039;t break poorly written admin scripts
RewriteRule .* - [S=1]
&#160;
RewriteCond %{HTTPS} =on [OR]
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule .* http://www.askapache.com%{REQUEST_URI} [R=301,L]
&#160;
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(wp-admin/.*&#124;wp-login\.php.*)\ HTTP/ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]</pre>]]></description>
			<content:encoded><![CDATA[<p>I was going through some backups from years ago, and ran:</p>
<pre>locate .htaccess | xargs -I&#039;{}&#039; cat &#039;{}&#039; &gt;&gt; master-htaccesser.txt</pre>
<p>My site is named after reading source code because that is what helps me the most when I&#8217;m trying to learn something unusually difficult.   Just like functions and aliases, it is very helpful to have cheatsheets for common commands.. not much is better than real-world examples.  Unfortunately because this was compiled from hundreds of htaccess files on multiple hosts and platforms, and due to the concatenation, it&#8217;s not organized.</p>
<p>Normally I would not publish something like this, who knows how much unreleased tricks I forgot about..  but in order to say thanks to all those working for open-source, the FSF, and to all those who don&#8217;t steal content, and to all the incredible authors who shared with me (I twitter most of what I find, and follow my favs), here ya go..</p>
<p class="cnote"><strong>ATTN:</strong> Please let me know if this is total junk or not, this is around 1/500th of my master-htaccesser.txt file.. and I&#8217;d be happy to post more if it helps..</p>
<h2>Checking for Cookie</h2>
<p>Used this to stop mp3-scrapers.. checks for a cookie ending in MP3P=02357</p>
<pre>Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !^.*MP3P=([0-9]+).* [NC]
RewriteRule .* - [F,L]</pre>
<h2>Setting Environment Var if Proxied</h2>
<pre>RewriteEngine On
RewriteRule &quot;\.(gif|png|jpg)$&quot; &quot;-&quot; [ENV=proxied_image:1]
RewriteCond &quot;%{ENV:proxied_image}&quot; &quot;!1&quot;
RewriteRule &quot;^&quot; &quot;-&quot; [ENV=proxied_other:1]</pre>
<h2>nokeepalive for ErrorDocs and Abusers</h2>
<pre>Options SymLinksIfOwnerMatch IncludesNOEXEC
AddOutputFilter Includes html
SetEnv nokeepalive
Order Allow,Deny
Allow from all
# 1 YEAR
&lt;FilesMatch &quot;\.(js|css)$&quot;&gt;
Header unset Pragma
FileETag None
Header set Cache-Control &quot;public&quot;
Header set Expires &quot;Thu, 15 Apr 2010 20:00:00 GMT&quot;
Header unset Last-Modified
Header unset Last-Modified
Header unset ETag
&nbsp;
SetOutputFilter DEFLATE
Header set Cache-Control &quot;public&quot;
Header set Expires &quot;Thu, 15 Apr 2010 20:00:00 GMT&quot;
&lt;/FilesMatch&gt;
SecFilterEngine Off
&nbsp;
# 1 YEAR
&lt;FilesMatch &quot;\.(js|css)$&quot;&gt;
Header unset Pragma
FileETag None
Header set Cache-Control &quot;public&quot;
Header set Expires &quot;Thu, 15 Apr 2010 20:00:00 GMT&quot;
Header unset Last-Modified
Header unset Last-Modified
Header unset ETag
&nbsp;
SetOutputFilter DEFLATE
Header set Cache-Control &quot;public&quot;
Header set Expires &quot;Thu, 15 Apr 2010 20:00:00 GMT&quot;
&lt;/FilesMatch&gt;</pre>
<h2>Unreleased Tests for AskApache Password Protection</h2>
<pre># +ASKAPACHE PASSPRO 4.6.6
#######################################################
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
# +APRO SIDS
# +SID 21030002
Order Deny,Allow
Deny from All
Satisfy Any
AuthType Digest
AuthName &quot;Protected By AskApache&quot;
AuthDigestDomain / http://www.askapache.com/
AuthDigestFile /home/.greer/askapache/sites/askapache.com/.htpasswda3
Require valid-user
&lt;FilesMatch &quot;\.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$&quot;&gt;
Allow from All
&lt;/FilesMatch&gt;
&lt;FilesMatch &quot;(async-upload|admin-ajax)\.php$&quot;&gt;
&lt;IfModule mod_security.c&gt;
SecFilterEngine Off
&lt;/IfModule&gt;
Allow from All
&lt;/FilesMatch&gt;
# -SID 21030002
# -APRO SIDS
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
#######################################################
# -ASKAPACHE PASSPRO 4.6.6
&nbsp;
# +ASKAPACHE PASSPRO 4.6.6
#######################################################
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
# +APRO SIDS
# +SID Test
ErrorDocument 401 /wp-content/askapache/test.gif
ErrorDocument 403 /wp-content/askapache/test.gif
ErrorDocument 404 /wp-content/askapache/test.gif
ErrorDocument 500 /wp-content/askapache/test.gif
ServerSignature On
&lt;IfModule mod_alias.c&gt;
RedirectMatch 305 ^.*modaliastest$ http://www.askapache.com
&lt;/IfModule&gt;
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} modrewritetest [NC]
RewriteRule .* http://www.askapache.com [R=307,L]
&lt;/IfModule&gt;
&lt;Files modsec_check.gif&gt;
&lt;IfModule mod_security.c&gt;
SetEnv MODSEC_ENABLE On
SecFilterEngine On
SecFilterDefaultAction &quot;nolog,noauditlog,pass&quot;
SecAuditEngine Off
SecFilterInheritance Off
SecFilter modsecuritytest &quot;deny,nolog,noauditlog,status:503&quot;
Deny from All
&lt;/IfModule&gt;
&lt;/Files&gt;
&lt;Files basic_auth_test.gif&gt;
AuthType Basic
AuthName &quot;askapache test&quot;
AuthUserFile /home/.greer/askapache/sites/askapache.com/htdocs/wp-content/askapache/.htpasswd-basic
Require valid-user
&lt;/Files&gt;
&lt;Files digest_check.gif&gt;
AuthType Digest
AuthName &quot;askapache test&quot;
AuthDigestDomain /wp-content/askapache/ http://www.askapache.com/wp-content/askapache/
AuthUserFile /home/.greer/askapache/sites/askapache.com/htdocs/wp-content/askapache/.htpasswd-digest
Require none
&lt;/Files&gt;
&lt;Files authuserfile_test.gif&gt;
AuthType Digest
AuthName &quot;askapache test&quot;
AuthDigestDomain /wp-content/askapache/ http://www.askapache.com/wp-content/askapache/
AuthUserFile /home/.greer/askapache/sites/askapache.com/htdocs/wp-content/askapache/.htpasswd-digest
Require valid-user
&lt;/Files&gt;
&lt;Files authdigestfile_test.gif&gt;
AuthType Digest
AuthName &quot;askapache test&quot;
AuthDigestDomain /wp-content/askapache/ http://www.askapache.com/wp-content/askapache/
AuthDigestFile /home/.greer/askapache/sites/askapache.com/htdocs/wp-content/askapache/.htpasswd-digest
Require valid-user
&lt;/Files&gt;
# -SID Test
# -APRO SIDS
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
#######################################################
# -ASKAPACHE PASSPRO 4.6.6</pre>
<h2>Warming up to the really advanced tests</h2>
<pre>Options +ExecCGI
Order Deny,Allow
Deny from All
Allow from 208.113.134.190 64.111.114.111 208.113.134.203 208.113.152.201 env=REDIRECT_STATUS
Satisfy Any
Options +FollowSymLinks
AddHandler application/x-httpd-php .php
&nbsp;
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !^tyy+$ [NC]
RewriteCond %{REMOTE_USER} ^(.+)$
RewriteRule ^(.*)$ $1/-%1 [R=302,L]
Options +ExecCGI +FollowSymLinks
DirectoryIndex index.php
ErrorDocument 404 /cgi-bin/pro/index.php
&nbsp;
AuthType Digest
AuthName &quot;AskApache Pro&quot;
AuthDigestFile /home/askapache/sites/askapache.com/.htpasswd-pro
AuthDigestDomain /cgi-bin/pro/ http://www.askapache.com/cgi-bin/pro/ https://www.askapache.com/cgi-bin/pro/
Require user askapacheDirectoryIndex p.php
ErrorDocument 403 /cgi-bin/p/p.php
ErrorDocument 401 /cgi-bin/p/p.php
ErrorDocument 500 /cgi-bin/p/p.php
ErrorDocument 503 /cgi-bin/p/p.php
&nbsp;
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=INFO_API_VERSION:%{API_VERSION}]
RewriteRule .* - [E=INFO_AUTH_TYPE:%{AUTH_TYPE}]
RewriteRule .* - [E=INFO_CONTENT_LENGTH:%{CONTENT_LENGTH}]
RewriteRule .* - [E=INFO_CONTENT_TYPE:%{CONTENT_TYPE}]
RewriteRule .* - [E=INFO_DOCUMENT_ROOT:%{DOCUMENT_ROOT}]
RewriteRule .* - [E=INFO_GATEWAY_INTERFACE:%{GATEWAY_INTERFACE}]
RewriteRule .* - [E=INFO_HTTPS:%{HTTPS}]
RewriteRule .* - [E=INFO_HTTP_ACCEPT:%{HTTP:Accept}]
RewriteRule .* - [E=INFO_HTTP_ACCEPT_LANGUAGE:%{HTTP:Accept-Language}]
RewriteRule .* - [E=INFO_HTTP_ACCEPT_ENCODING:%{HTTP:Accept-Encoding}]
RewriteRule .* - [E=INFO_HTTP_ACCEPT_CHARSET:%{HTTP:Accept-Charset}]
RewriteRule .* - [E=INFO_HTTP_CACHE_CONTROL:%{HTTP:Cache-Control}]
RewriteRule .* - [E=INFO_HTTP_CONNECTION:%{HTTP:Connection}]
RewriteRule .* - [E=INFO_HTTP_COOKIE:%{HTTP_COOKIE}]
RewriteRule .* - [E=INFO_HTTP_FORWARDED:%{HTTP_FORWARDED}]
RewriteRule .* - [E=INFO_HTTP_HOST:%{HTTP_HOST}]
RewriteRule .* - [E=INFO_HTTP_KEEP_ALIVE:%{HTTP_KEEP_ALIVE}]
RewriteRule .* - [E=INFO_HTTP_PROXY_CONNECTION:%{HTTP_PROXY_CONNECTION}]
RewriteRule .* - [E=INFO_HTTP_REFERER:%{HTTP:Referer}]
RewriteRule .* - [E=INFO_HTTP_USER_AGENT:%{HTTP_USER_AGENT}]
RewriteRule .* - [E=INFO_IS_SUBREQ:%{IS_SUBREQ}]
RewriteRule .* - [E=INFO_ORIG_PATH_INFO:%{ORIG_PATH_INFO}]
RewriteRule .* - [E=INFO_ORIG_PATH_TRANSLATED:%{ORIG_PATH_TRANSLATED}]
RewriteRule .* - [E=INFO_ORIG_SCRIPT_FILENAME:%{ORIG_SCRIPT_FILENAME}]
RewriteRule .* - [E=INFO_ORIG_SCRIPT_NAME:%{ORIG_SCRIPT_NAME}]
RewriteRule .* - [E=INFO_PATH:%{PATH}]
RewriteRule .* - [E=INFO_PATH_INFO:%{PATH_INFO}]
RewriteRule .* - [E=INFO_QUERY_STRING:%{QUERY_STRING}]
RewriteRule .* - [E=INFO_REDIRECT_QUERY_STRING:%{REDIRECT_QUERY_STRING}]
RewriteRule .* - [E=INFO_REDIRECT_REMOTE_USER:%{REDIRECT_REMOTE_USER}]
RewriteRule .* - [E=INFO_REDIRECT_STATUS:%{REDIRECT_STATUS}]
RewriteRule .* - [E=INFO_REDIRECT_URL:%{REDIRECT_URL}]
RewriteRule .* - [E=INFO_REMOTE_ADDR:%{REMOTE_ADDR}]
RewriteRule .* - [E=INFO_REMOTE_HOST:%{REMOTE_HOST}]
RewriteRule .* - [E=INFO_REMOTE_IDENT:%{REMOTE_IDENT}]
RewriteRule .* - [E=INFO_REMOTE_PORT:%{REMOTE_PORT}]
RewriteRule .* - [E=INFO_REMOTE_USER:%{REMOTE_USER}]
RewriteRule .* - [E=INFO_REQUEST_FILENAME:%{REQUEST_FILENAME}]
RewriteRule .* - [E=INFO_REQUEST_METHOD:%{REQUEST_METHOD}]
RewriteRule .* - [E=INFO_REQUEST_URI:%{REQUEST_URI}]
RewriteRule .* - [E=INFO_REDIRECT_REQUEST_URI:%{REDIRECT_REQUEST_URI}]
RewriteRule .* - [E=INFO_SCRIPT_FILENAME:%{SCRIPT_FILENAME}]
RewriteRule .* - [E=INFO_SCRIPT_GROUP:%{SCRIPT_GROUP}]
RewriteRule .* - [E=INFO_SCRIPT_NAME:%{SCRIPT_NAME}]
RewriteRule .* - [E=INFO_SCRIPT_URI:%{SCRIPT_URI}]
RewriteRule .* - [E=INFO_SCRIPT_URL:%{SCRIPT_URL}]
RewriteRule .* - [E=INFO_SCRIPT_USER:%{SCRIPT_USER}]
RewriteRule .* - [E=INFO_SERVER_ADDR:%{SERVER_ADDR}]
RewriteRule .* - [E=INFO_SERVER_ADMIN:%{SERVER_ADMIN}]
RewriteRule .* - [E=INFO_SERVER_NAME:%{SERVER_NAME}]
RewriteRule .* - [E=INFO_SERVER_PORT:%{SERVER_PORT}]
RewriteRule .* - [E=INFO_SERVER_PROTOCOL:%{SERVER_PROTOCOL}]
RewriteRule .* - [E=INFO_SERVER_SIGNATURE:%{SERVER_SIGNATURE}]
RewriteRule .* - [E=INFO_SERVER_SOFTWARE:%{SERVER_SOFTWARE}]
RewriteRule .* - [E=INFO_THE_REQUEST:%{THE_REQUEST}]
RewriteRule .* - [E=INFO_TIME:%{TIME}]
RewriteRule .* - [E=INFO_TIME_DAY:%{TIME_DAY}]
RewriteRule .* - [E=INFO_TIME_HOUR:%{TIME_HOUR}]
RewriteRule .* - [E=INFO_TIME_MIN:%{TIME_MIN}]
RewriteRule .* - [E=INFO_TIME_MON:%{TIME_MON}]
RewriteRule .* - [E=INFO_TIME_SEC:%{TIME_SEC}]
RewriteRule .* - [E=INFO_TIME_WDAY:%{TIME_WDAY}]
RewriteRule .* - [E=INFO_TIME_YEAR:%{TIME_YEAR}]
RewriteRule .* - [E=INFO_TZ:%{TZ}]
RewriteRule .* - [E=INFO_UNIQUE_ID:%{UNIQUE_ID}]
&nbsp;
RequestHeader set INFO_API_VERSION &quot;%{INFO_API_VERSION}e&quot;
RequestHeader set INFO_AUTH_TYPE &quot;%{INFO_AUTH_TYPE}e&quot;
RequestHeader set INFO_CONTENT_LENGTH &quot;%{INFO_CONTENT_LENGTH}e&quot;
RequestHeader set INFO_CONTENT_TYPE &quot;%{INFO_CONTENT_TYPE}e&quot;
RequestHeader set INFO_DOCUMENT_ROOT &quot;%{INFO_DOCUMENT_ROOT}e&quot;
RequestHeader set INFO_GATEWAY_INTERFACE &quot;%{INFO_GATEWAY_INTERFACE}e&quot;
RequestHeader set INFO_HTTPS &quot;%{INFO_HTTPS}e&quot;
RequestHeader set INFO_HTTP_ACCEPT &quot;%{INFO_HTTP_ACCEPT}e&quot;
RequestHeader set INFO_HTTP_ACCEPT_LANGUAGE &quot;%{INFO_HTTP_ACCEPT_LANGUAGE}e&quot;
RequestHeader set INFO_HTTP_ACCEPT_ENCODING &quot;%{INFO_HTTP_ACCEPT_ENCODING}e&quot;
RequestHeader set INFO_HTTP_ACCEPT_CHARSET &quot;%{INFO_HTTP_ACCEPT_CHARSET}e&quot;
RequestHeader set INFO_HTTP_CACHE_CONTROL &quot;%{INFO_HTTP_CACHE_CONTROL}e&quot;
RequestHeader set INFO_HTTP_CONNECTION &quot;%{INFO_HTTP_CONNECTION}e&quot;
RequestHeader set INFO_HTTP_COOKIE &quot;%{INFO_HTTP_COOKIE}e&quot;
RequestHeader set INFO_HTTP_FORWARDED &quot;%{INFO_HTTP_FORWARDED}e&quot;
RequestHeader set INFO_HTTP_HOST &quot;%{INFO_HTTP_HOST}e&quot;
RequestHeader set INFO_HTTP_KEEP_ALIVE &quot;%{INFO_HTTP_KEEP_ALIVE}e&quot;
RequestHeader set INFO_HTTP_PROXY_CONNECTION &quot;%{INFO_HTTP_PROXY_CONNECTION}e&quot;
RequestHeader set INFO_HTTP_REFERER &quot;%{INFO_HTTP_REFERER}e&quot;
RequestHeader set INFO_HTTP_USER_AGENT &quot;%{INFO_HTTP_USER_AGENT}e&quot;
RequestHeader set INFO_IS_SUBREQ &quot;%{INFO_IS_SUBREQ}e&quot;
RequestHeader set INFO_ORIG_PATH_INFO &quot;%{INFO_ORIG_PATH_INFO}e&quot;
RequestHeader set INFO_ORIG_PATH_TRANSLATED &quot;%{INFO_ORIG_PATH_TRANSLATED}e&quot;
RequestHeader set INFO_ORIG_SCRIPT_FILENAME &quot;%{INFO_ORIG_SCRIPT_FILENAME}e&quot;
RequestHeader set INFO_ORIG_SCRIPT_NAME &quot;%{INFO_ORIG_SCRIPT_NAME}e&quot;
RequestHeader set INFO_PATH &quot;%{INFO_PATH}e&quot;
RequestHeader set INFO_PATH_INFO &quot;%{INFO_PATH_INFO}e&quot;
RequestHeader set INFO_QUERY_STRING &quot;%{INFO_QUERY_STRING}e&quot;
RequestHeader set INFO_REDIRECT_QUERY_STRING &quot;%{INFO_REDIRECT_QUERY_STRING}e&quot;
RequestHeader set INFO_REDIRECT_REMOTE_USER &quot;%{INFO_REDIRECT_REMOTE_USER}e&quot;
RequestHeader set INFO_REDIRECT_STATUS &quot;%{INFO_REDIRECT_STATUS}e&quot;
RequestHeader set INFO_REDIRECT_URL &quot;%{INFO_REDIRECT_URL}e&quot;
RequestHeader set INFO_REMOTE_ADDR &quot;%{INFO_REMOTE_ADDR}e&quot;
RequestHeader set INFO_REMOTE_HOST &quot;%{INFO_REMOTE_HOST}e&quot;
RequestHeader set INFO_REMOTE_IDENT &quot;%{INFO_REMOTE_IDENT}e&quot;
RequestHeader set INFO_REMOTE_PORT &quot;%{INFO_REMOTE_PORT}e&quot;
RequestHeader set INFO_REMOTE_USER &quot;%{INFO_REMOTE_USER}e&quot;
RequestHeader set INFO_REQUEST_FILENAME &quot;%{INFO_REQUEST_FILENAME}e&quot;
RequestHeader set INFO_REQUEST_METHOD &quot;%{INFO_REQUEST_METHOD}e&quot;
RequestHeader set INFO_REQUEST_URI &quot;%{INFO_REQUEST_URI}e&quot;
RequestHeader set INFO_REQUEST_URI &quot;%{INFO_REQUEST_URI}e&quot;
RequestHeader set INFO_SCRIPT_FILENAME &quot;%{INFO_SCRIPT_FILENAME}e&quot;
RequestHeader set INFO_SCRIPT_GROUP &quot;%{INFO_SCRIPT_GROUP}e&quot;
RequestHeader set INFO_SCRIPT_NAME &quot;%{INFO_SCRIPT_NAME}e&quot;
RequestHeader set INFO_SCRIPT_URI &quot;%{INFO_SCRIPT_URI}e&quot;
RequestHeader set INFO_SCRIPT_URL &quot;%{INFO_SCRIPT_URL}e&quot;
RequestHeader set INFO_SCRIPT_USER &quot;%{INFO_SCRIPT_USER}e&quot;
RequestHeader set INFO_SERVER_ADDR &quot;%{INFO_SERVER_ADDR}e&quot;
RequestHeader set INFO_SERVER_ADMIN &quot;%{INFO_SERVER_ADMIN}e&quot;
RequestHeader set INFO_SERVER_NAME &quot;%{INFO_SERVER_NAME}e&quot;
RequestHeader set INFO_SERVER_PORT &quot;%{INFO_SERVER_PORT}e&quot;
RequestHeader set INFO_SERVER_PROTOCOL &quot;%{INFO_SERVER_PROTOCOL}e&quot;
RequestHeader set INFO_SERVER_SIGNATURE &quot;%{INFO_SERVER_SIGNATURE}e&quot;
RequestHeader set INFO_SERVER_SOFTWARE &quot;%{INFO_SERVER_SOFTWARE}e&quot;
RequestHeader set INFO_THE_REQUEST &quot;%{INFO_THE_REQUEST}e&quot;
RequestHeader set INFO_TIME &quot;%{INFO_TIME}e&quot;
RequestHeader set INFO_TIME_DAY &quot;%{INFO_TIME_DAY}e&quot;
RequestHeader set INFO_TIME_HOUR &quot;%{INFO_TIME_HOUR}e&quot;
RequestHeader set INFO_TIME_MIN &quot;%{INFO_TIME_MIN}e&quot;
RequestHeader set INFO_TIME_MON &quot;%{INFO_TIME_MON}e&quot;
RequestHeader set INFO_TIME_SEC &quot;%{INFO_TIME_SEC}e&quot;
RequestHeader set INFO_TIME_WDAY &quot;%{INFO_TIME_WDAY}e&quot;
RequestHeader set INFO_TIME_YEAR &quot;%{INFO_TIME_YEAR}e&quot;
RequestHeader set INFO_TZ &quot;%{INFO_TZ}e&quot;
RequestHeader set INFO_UNIQUE_ID &quot;%{INFO_UNIQUE_ID}e&quot;
&nbsp;
Options +FollowSymLinks +ExecCGI
DirectoryIndex /cgi-bin/rewrite-test/index.php
&nbsp;
Header echo ^.*
&nbsp;
AuthType Digest
AuthName &quot;AskApache Pro&quot;
AuthDigestFile /home/askapache/sites/askapache.com/.htpasswd-pro
AuthDigestDomain / http://www.askapache.com/cgi-bin/rewrite-test/ https://www.askapache.com/cgi-bin/rewrite-test/
Require user askapache
&nbsp;
SetEnv MODSEC_ENABLE=On
&nbsp;
SetEnvIfNoCase ^WWW-Auth &quot;(.+)&quot; HTTP_WWW_AUTHORIZATION=$1
SetEnvIfNoCase ^If &quot;(.+)&quot; HTTP_IF_MODIFIED_SINCE=$1
SetEnvIfNoCase ^If-None-Match$ &quot;(.+)&quot; HTTP_IF_NONE_MATCH=$1
SetEnvIfNoCase ^Cache-Control$ &quot;(.+)&quot; HTTP_CACHE_CONTROL=$1
SetEnvIfNoCase ^Connection$ &quot;(.+)&quot; HTTP_CONNECTION=$1
SetEnvIfNoCase ^Keep-Alive$ &quot;(.+)&quot; HTTP_KEEP_ALIVE=$1
SetEnvIfNoCase ^Authorization$ &quot;(.+)&quot; HTTP_AUTHORIZATION=$1
SetEnvIfNoCase ^Authorization$ &quot;.+username=\&quot;(.+)\&quot;.+&quot; HTTP_REMOTE_USER=$1
SetEnvIfNoCase ^Content-Type$ &quot;(.+)&quot; HTTP_CONTENT_TYPE=$1
SetEnvIfNoCase ^Content-Length$ &quot;(.+)&quot; HTTP_CONTENT_LENGTH=$1
SetEnvIfNoCase Server_Addr &quot;(.+)&quot; SERVER_ADDR=$1
SetEnvIfNoCase Request_Method &quot;(.+)&quot; REQUEST_METHOD=$1
SetEnvIfNoCase Request_Protocol &quot;(.+)&quot; REQUEST_PROTOCOL=$1
SetEnvIfNoCase Request_URI &quot;(.+)&quot; REQUEST_URI=$1
&nbsp;
ErrorDocument 100 /cgi-bin/rewrite-test/index.php?g=100
ErrorDocument 101 /cgi-bin/rewrite-test/index.php?g=101
ErrorDocument 102 /cgi-bin/rewrite-test/index.php?g=102
ErrorDocument 200 /cgi-bin/rewrite-test/index.php?g=200
ErrorDocument 201 /cgi-bin/rewrite-test/index.php?g=201
ErrorDocument 202 /cgi-bin/rewrite-test/index.php?g=202
ErrorDocument 203 /cgi-bin/rewrite-test/index.php?g=203
ErrorDocument 204 /cgi-bin/rewrite-test/index.php?g=204
ErrorDocument 205 /cgi-bin/rewrite-test/index.php?g=205
ErrorDocument 206 /cgi-bin/rewrite-test/index.php?g=206
ErrorDocument 207 /cgi-bin/rewrite-test/index.php?g=207
ErrorDocument 300 /cgi-bin/rewrite-test/index.php?g=300
ErrorDocument 301 /cgi-bin/rewrite-test/index.php?g=301
ErrorDocument 302 /cgi-bin/rewrite-test/index.php?g=302
ErrorDocument 303 /cgi-bin/rewrite-test/index.php?g=303
ErrorDocument 304 /cgi-bin/rewrite-test/index.php?g=304
ErrorDocument 305 /cgi-bin/rewrite-test/index.php?g=305
ErrorDocument 306 /cgi-bin/rewrite-test/index.php?g=306
ErrorDocument 307 /cgi-bin/rewrite-test/index.php?g=307
ErrorDocument 400 /cgi-bin/rewrite-test/index.php?g=400
ErrorDocument 401 /cgi-bin/rewrite-test/index.php?g=401
ErrorDocument 402 /cgi-bin/rewrite-test/index.php?g=402
ErrorDocument 403 /cgi-bin/rewrite-test/index.php?g=403
ErrorDocument 404 /cgi-bin/rewrite-test/index.php?g=404
ErrorDocument 405 /cgi-bin/rewrite-test/index.php?g=405
ErrorDocument 406 /cgi-bin/rewrite-test/index.php?g=406
ErrorDocument 407 /cgi-bin/rewrite-test/index.php?g=407
ErrorDocument 408 /cgi-bin/rewrite-test/index.php?g=408
ErrorDocument 409 /cgi-bin/rewrite-test/index.php?g=409
ErrorDocument 410 /cgi-bin/rewrite-test/index.php?g=410
ErrorDocument 411 /cgi-bin/rewrite-test/index.php?g=411
ErrorDocument 412 /cgi-bin/rewrite-test/index.php?g=412
ErrorDocument 413 /cgi-bin/rewrite-test/index.php?g=413
ErrorDocument 414 /cgi-bin/rewrite-test/index.php?g=414
ErrorDocument 415 /cgi-bin/rewrite-test/index.php?g=415
ErrorDocument 416 /cgi-bin/rewrite-test/index.php?g=416
ErrorDocument 417 /cgi-bin/rewrite-test/index.php?g=417
ErrorDocument 418 /cgi-bin/rewrite-test/index.php?g=418
ErrorDocument 419 /cgi-bin/rewrite-test/index.php?g=419
ErrorDocument 420 /cgi-bin/rewrite-test/index.php?g=420
ErrorDocument 421 /cgi-bin/rewrite-test/index.php?g=421
ErrorDocument 422 /cgi-bin/rewrite-test/index.php?g=422
ErrorDocument 423 /cgi-bin/rewrite-test/index.php?g=423
ErrorDocument 424 /cgi-bin/rewrite-test/index.php?g=424
ErrorDocument 425 /cgi-bin/rewrite-test/index.php?g=425
ErrorDocument 426 /cgi-bin/rewrite-test/index.php?g=426
ErrorDocument 500 /cgi-bin/rewrite-test/index.php?g=500
ErrorDocument 501 /cgi-bin/rewrite-test/index.php?g=501
ErrorDocument 502 /cgi-bin/rewrite-test/index.php?g=502
ErrorDocument 503 /cgi-bin/rewrite-test/index.php?g=503
ErrorDocument 504 /cgi-bin/rewrite-test/index.php?g=504
ErrorDocument 505 /cgi-bin/rewrite-test/index.php?g=505
ErrorDocument 506 /cgi-bin/rewrite-test/index.php?g=506
ErrorDocument 507 /cgi-bin/rewrite-test/index.php?g=507
ErrorDocument 508 /cgi-bin/rewrite-test/index.php?g=508
ErrorDocument 509 /cgi-bin/rewrite-test/index.php?g=509
ErrorDocument 510 /cgi-bin/rewrite-test/index.php?g=510
&nbsp;
RewriteEngine On
RewriteBase /
&nbsp;
RewriteRule .* - [E=IN_AUTH_TYPE:%{AUTH_TYPE}]
RewriteRule .* - [E=IN_CONTENT_LENGTH:%{CONTENT_LENGTH}]
RewriteRule .* - [E=IN_CONTENT_TYPE:%{CONTENT_TYPE}]
RewriteRule .* - [E=IN_DATE_GMT:%{DATE_GMT}]
RewriteRule .* - [E=IN_DATE_LOCAL:%{DATE_LOCAL}]
RewriteRule .* - [E=IN_DOCUMENT_NAME:%{DOCUMENT_NAME}]
RewriteRule .* - [E=IN_DOCUMENT_PATH_INFO:%{DOCUMENT_PATH_INFO}]
RewriteRule .* - [E=IN_DOCUMENT_ROOT:%{DOCUMENT_ROOT}]
RewriteRule .* - [E=IN_DOCUMENT_URI:%{DOCUMENT_URI}]
RewriteRule .* - [E=IN_GATEWAY_INTERFACE:%{GATEWAY_INTERFACE}]
RewriteRule .* - [E=IN_LAST_MODIFIED:%{LAST_MODIFIED}]
RewriteRule .* - [E=IN_PATH_INFO:%{PATH_INFO}]
RewriteRule .* - [E=IN_PATH_TRANSLATED:%{PATH_TRANSLATED}]
RewriteRule .* - [E=IN_QUERY_STRING:%{QUERY_STRING}]
RewriteRule .* - [E=IN_QUERY_STRING_UNESCAPED:%{QUERY_STRING_UNESCAPED}]
RewriteRule .* - [E=IN_REMOTE_ADDR:%{REMOTE_ADDR}]
RewriteRule .* - [E=IN_REMOTE_HOST:%{REMOTE_HOST}]
RewriteRule .* - [E=IN_REMOTE_IDENT:%{REMOTE_IDENT}]
RewriteRule .* - [E=IN_REMOTE_PORT:%{REMOTE_PORT}]
RewriteRule .* - [E=IN_REMOTE_USER:%{REMOTE_USER}]
RewriteRule .* - [E=IN_REDIRECT_HANDLER:%{REDIRECT_HANDLER}]
RewriteRule .* - [E=IN_REDIRECT_QUERY_STRING:%{REDIRECT_QUERY_STRING}]
RewriteRule .* - [E=IN_REDIRECT_REMOTE_USER:%{REDIRECT_REMOTE_USER}]
RewriteRule .* - [E=IN_REDIRECT_STATUS:%{REDIRECT_STATUS}]
RewriteRule .* - [E=IN_REDIRECT_URL:%{REDIRECT_URL}]
RewriteRule .* - [E=IN_REQUEST_METHOD:%{REQUEST_METHOD}]
RewriteRule .* - [E=IN_REQUEST_URI:%{REQUEST_URI}]
RewriteRule .* - [E=IN_SCRIPT_FILENAME:%{SCRIPT_FILENAME}]
RewriteRule .* - [E=IN_SCRIPT_NAME:%{SCRIPT_NAME}]
RewriteRule .* - [E=IN_SERVER_ADMIN:%{SERVER_ADMIN}]
RewriteRule .* - [E=IN_SERVER_NAME:%{SERVER_NAME}]
RewriteRule .* - [E=IN_SERVER_ADDR:%{SERVER_ADDR}]
RewriteRule .* - [E=IN_SERVER_PORT:%{SERVER_PORT}]
RewriteRule .* - [E=IN_SERVER_PROTOCOL:%{SERVER_PROTOCOL}]
RewriteRule .* - [E=IN_SERVER_SIGNATURE:%{SERVER_SIGNATURE}]
RewriteRule .* - [E=IN_SERVER_SOFTWARE:%{SERVER_SOFTWARE}]
RewriteRule .* - [E=IN_USER_NAME:%{USER_NAME}]
RewriteRule .* - [E=IN_TZ:%{TZ}]
RewriteRule .* - [E=IN_API_VERSION:%{API_VERSION}]
RewriteRule .* - [E=IN_HTTPS:%{HTTPS}]
RewriteRule .* - [E=IN_HTTP_ACCEPT:%{HTTP_ACCEPT}]
RewriteRule .* - [E=IN_HTTP_ACCEPT_CHARSET:%{HTTP_ACCEPT_CHARSET}]
RewriteRule .* - [E=IN_HTTP_ACCEPT_ENCODING:%{HTTP_ACCEPT_ENCODING}]
RewriteRule .* - [E=IN_HTTP_ACCEPT_LANGUAGE:%{HTTP_ACCEPT_LANGUAGE}]
RewriteRule .* - [E=IN_HTTP_CACHE_CONTROL:%{HTTP_CACHE_CONTROL}]
RewriteRule .* - [E=IN_HTTP_CONNECTION:%{HTTP_CONNECTION}]
RewriteRule .* - [E=IN_HTTP_COOKIE:%{HTTP_COOKIE}]
RewriteRule .* - [E=IN_HTTP_FORWARDED:%{HTTP_FORWARDED}]
RewriteRule .* - [E=IN_HTTP_HOST:%{HTTP_HOST}]
RewriteRule .* - [E=IN_HTTP_KEEP_ALIVE:%{HTTP_KEEP_ALIVE}]
RewriteRule .* - [E=IN_HTTP_PROXY_CONNECTION:%{HTTP_PROXY_CONNECTION}]
RewriteRule .* - [E=IN_HTTP_REFERER:%{HTTP_REFERER}]
RewriteRule .* - [E=IN_HTTP_USER_AGENT:%{HTTP_USER_AGENT}]
RewriteRule .* - [E=IN_IS_SUBREQ:%{IS_SUBREQ}]
RewriteRule .* - [E=IN_ORIG_PATH_INFO:%{ORIG_PATH_INFO}]
RewriteRule .* - [E=IN_ORIG_PATH_TRANSLATED:%{ORIG_PATH_TRANSLATED}]
RewriteRule .* - [E=IN_ORIG_SCRIPT_FILENAME:%{ORIG_SCRIPT_FILENAME}]
RewriteRule .* - [E=IN_ORIG_SCRIPT_NAME:%{ORIG_SCRIPT_NAME}]
RewriteRule .* - [E=IN_PATH:%{PATH}]
RewriteRule .* - [E=IN_PHP_SELF:%{PHP_SELF}]
RewriteRule .* - [E=IN_REQUEST_FILENAME:%{REQUEST_FILENAME}]
RewriteRule .* - [E=IN_REQUEST_TIME:%{REQUEST_TIME}]
RewriteRule .* - [E=IN_SCRIPT_GROUP:%{SCRIPT_GROUP}]
RewriteRule .* - [E=IN_SCRIPT_USER:%{SCRIPT_USER}]
RewriteRule .* - [E=IN_THE_REQUEST:%{THE_REQUEST}]
RewriteRule .* - [E=IN_TIME:%{TIME}]
RewriteRule .* - [E=IN_TIME_DAY:%{TIME_DAY}]
RewriteRule .* - [E=IN_TIME_HOUR:%{TIME_HOUR}]
RewriteRule .* - [E=IN_TIME_MIN:%{TIME_MIN}]
RewriteRule .* - [E=IN_TIME_MON:%{TIME_MON}]
RewriteRule .* - [E=IN_TIME_SEC:%{TIME_SEC}]
RewriteRule .* - [E=IN_TIME_WDAY:%{TIME_WDAY}]
RewriteRule .* - [E=IN_TIME_YEAR:%{TIME_YEAR}]
RewriteRule .* - [E=IN_PATH:%{PATH}]
RewriteRule .* - [E=IN_SCRIPT_URI:%{SCRIPT_URI}]
RewriteRule .* - [E=IN_SCRIPT_URL:%{SCRIPT_URL}]
RewriteRule .* - [E=IN_UNIQUE_ID:%{UNIQUE_ID}]
&nbsp;
RewriteRule .* - [E=ENV_PATH:%{ENV:PATH}]
RewriteRule .* - [E=ENV_SCRIPT_URI:%{ENV:SCRIPT_URI}]
RewriteRule .* - [E=ENV_SCRIPT_URL:%{ENV:SCRIPT_URL}]
RewriteRule .* - [E=ENV_UNIQUE_ID:%{ENV:UNIQUE_ID}]
&nbsp;
RequestHeader set AUTH_TYPE &quot;%{IN_AUTH_TYPE}e&quot;
RequestHeader set CONTENT_LENGTH &quot;%{IN_CONTENT_LENGTH}e&quot;
RequestHeader set CONTENT_TYPE &quot;%{IN_CONTENT_TYPE}e&quot;
RequestHeader set DATE_GMT &quot;%{IN_DATE_GMT}e&quot;
RequestHeader set DATE_LOCAL &quot;%{IN_DATE_LOCAL}e&quot;
RequestHeader set DOCUMENT_NAME &quot;%{IN_DOCUMENT_NAME}e&quot;
RequestHeader set DOCUMENT_PATH_INFO &quot;%{IN_DOCUMENT_PATH_INFO}e&quot;
RequestHeader set DOCUMENT_ROOT &quot;%{IN_DOCUMENT_ROOT}e&quot;
RequestHeader set DOCUMENT_URI &quot;%{IN_DOCUMENT_URI}e&quot;
RequestHeader set GATEWAY_INTERFACE &quot;%{IN_GATEWAY_INTERFACE}e&quot;
RequestHeader set LAST_MODIFIED &quot;%{IN_LAST_MODIFIED}e&quot;
RequestHeader set PATH_INFO &quot;%{IN_PATH_INFO}e&quot;
RequestHeader set PATH_TRANSLATED &quot;%{IN_PATH_TRANSLATED}e&quot;
RequestHeader set QUERY_STRING &quot;%{IN_QUERY_STRING}e&quot;
RequestHeader set QUERY_STRING_UNESCAPED &quot;%{IN_QUERY_STRING_UNESCAPED}e&quot;
RequestHeader set REMOTE_ADDR &quot;%{IN_REMOTE_ADDR}e&quot;
RequestHeader set REMOTE_HOST &quot;%{IN_REMOTE_HOST}e&quot;
RequestHeader set REMOTE_IDENT &quot;%{IN_REMOTE_IDENT}e&quot;
RequestHeader set REMOTE_PORT &quot;%{IN_REMOTE_PORT}e&quot;
RequestHeader set REMOTE_USER &quot;%{IN_REMOTE_USER}e&quot;
RequestHeader set REDIRECT_HANDLER &quot;%{IN_REDIRECT_HANDLER}e&quot;
RequestHeader set REDIRECT_QUERY_STRING &quot;%{IN_REDIRECT_QUERY_STRING}e&quot;
RequestHeader set REDIRECT_REMOTE_USER &quot;%{IN_REDIRECT_REMOTE_USER}e&quot;
RequestHeader set REDIRECT_STATUS &quot;%{IN_REDIRECT_STATUS}e&quot;
RequestHeader set REDIRECT_URL &quot;%{IN_REDIRECT_URL}e&quot;
RequestHeader set REQUEST_METHOD &quot;%{IN_REQUEST_METHOD}e&quot;
RequestHeader set REQUEST_URI &quot;%{IN_REQUEST_URI}e&quot;
RequestHeader set SCRIPT_FILENAME &quot;%{IN_SCRIPT_FILENAME}e&quot;
RequestHeader set SCRIPT_NAME &quot;%{IN_SCRIPT_NAME}e&quot;
RequestHeader set SCRIPT_URI &quot;%{IN_SCRIPT_URI}e&quot;
RequestHeader set SCRIPT_URL &quot;%{IN_SCRIPT_URL}e&quot;
RequestHeader set SERVER_ADMIN &quot;%{IN_SERVER_ADMIN}e&quot;
RequestHeader set SERVER_NAME &quot;%{IN_SERVER_NAME}e&quot;
RequestHeader set SERVER_ADDR &quot;%{IN_SERVER_ADDR}e&quot;
RequestHeader set SERVER_PORT &quot;%{IN_SERVER_PORT}e&quot;
RequestHeader set SERVER_PROTOCOL &quot;%{IN_SERVER_PROTOCOL}e&quot;
RequestHeader set SERVER_SIGNATURE &quot;%{IN_SERVER_SIGNATURE}e&quot;
RequestHeader set SERVER_SOFTWARE &quot;%{IN_SERVER_SOFTWARE}e&quot;
RequestHeader set UNIQUE_ID &quot;%{IN_UNIQUE_ID}e&quot;
RequestHeader set USER_NAME &quot;%{IN_USER_NAME}e&quot;
RequestHeader set TZ &quot;%{IN_TZ}e&quot;
RequestHeader set API_VERSION &quot;%{IN_API_VERSION}e&quot;
RequestHeader set HTTPS &quot;%{IN_HTTPS}e&quot;
RequestHeader set HTTP_ACCEPT &quot;%{IN_HTTP_ACCEPT}e&quot;
RequestHeader set HTTP_ACCEPT_CHARSET &quot;%{IN_HTTP_ACCEPT_CHARSET}e&quot;
RequestHeader set HTTP_ACCEPT_ENCODING &quot;%{IN_HTTP_ACCEPT_ENCODING}e&quot;
RequestHeader set HTTP_ACCEPT_LANGUAGE &quot;%{IN_HTTP_ACCEPT_LANGUAGE}e&quot;
RequestHeader set HTTP_CACHE_CONTROL &quot;%{IN_HTTP_CACHE_CONTROL}e&quot;
RequestHeader set HTTP_CONNECTION &quot;%{IN_HTTP_CONNECTION}e&quot;
RequestHeader set HTTP_COOKIE &quot;%{IN_HTTP_COOKIE}e&quot;
RequestHeader set HTTP_FORWARDED &quot;%{IN_HTTP_FORWARDED}e&quot;
RequestHeader set HTTP_HOST &quot;%{IN_HTTP_HOST}e&quot;
RequestHeader set HTTP_KEEP_ALIVE &quot;%{IN_HTTP_KEEP_ALIVE}e&quot;
RequestHeader set HTTP_PROXY_CONNECTION &quot;%{IN_HTTP_PROXY_CONNECTION}e&quot;
RequestHeader set HTTP_REFERER &quot;%{IN_HTTP_REFERER}e&quot;
RequestHeader set HTTP_USER_AGENT &quot;%{IN_HTTP_USER_AGENT}e&quot;
RequestHeader set IS_SUBREQ &quot;%{IN_IS_SUBREQ}e&quot;
RequestHeader set ORIG_PATH_INFO &quot;%{IN_ORIG_PATH_INFO}e&quot;
RequestHeader set ORIG_PATH_TRANSLATED &quot;%{IN_ORIG_PATH_TRANSLATED}e&quot;
RequestHeader set ORIG_SCRIPT_FILENAME &quot;%{IN_ORIG_SCRIPT_FILENAME}e&quot;
RequestHeader set ORIG_SCRIPT_NAME &quot;%{IN_ORIG_SCRIPT_NAME}e&quot;
RequestHeader set PATH &quot;%{IN_PATH}e&quot;
RequestHeader set PHP_SELF &quot;%{IN_PHP_SELF}e&quot;
RequestHeader set REQUEST_FILENAME &quot;%{IN_REQUEST_FILENAME}e&quot;
RequestHeader set REQUEST_TIME &quot;%{IN_REQUEST_TIME}e&quot;
RequestHeader set SCRIPT_GROUP &quot;%{IN_SCRIPT_GROUP}e&quot;
RequestHeader set SCRIPT_USER &quot;%{IN_SCRIPT_USER}e&quot;
RequestHeader set THE_REQUEST &quot;%{IN_THE_REQUEST}e&quot;
RequestHeader set TIME &quot;%{IN_TIME}e&quot;
RequestHeader set TIME_DAY &quot;%{IN_TIME_DAY}e&quot;
RequestHeader set TIME_HOUR &quot;%{IN_TIME_HOUR}e&quot;
RequestHeader set TIME_MIN &quot;%{IN_TIME_MIN}e&quot;
RequestHeader set TIME_MON &quot;%{IN_TIME_MON}e&quot;
RequestHeader set TIME_SEC &quot;%{IN_TIME_SEC}e&quot;
RequestHeader set TIME_WDAY &quot;%{IN_TIME_WDAY}e&quot;
RequestHeader set TIME_YEAR &quot;%{IN_TIME_YEAR}e&quot;
&nbsp;
SetEnvIfNoCase ^WWW-Auth &quot;(.+)&quot; HTTP_WWW_AUTHORIZATION=$1
SetEnvIfNoCase ^If &quot;(.+)&quot; HTTP_IF_MODIFIED_SINCE=$1
SetEnvIfNoCase ^If-None-Match$ &quot;(.+)&quot; HTTP_IF_NONE_MATCH=$1
SetEnvIfNoCase ^Cache-Control$ &quot;(.+)&quot; HTTP_CACHE_CONTROL=$1
SetEnvIfNoCase ^Connection$ &quot;(.+)&quot; HTTP_CONNECTION=$1
SetEnvIfNoCase ^Keep-Alive$ &quot;(.+)&quot; HTTP_KEEP_ALIVE=$1
SetEnvIfNoCase ^Authorization$ &quot;(.+)&quot; HTTP_AUTHORIZATION=$1
SetEnvIfNoCase ^Content-Type$ &quot;(.+)&quot; HTTP_CONTENT_TYPE=$1
SetEnvIfNoCase ^Content-Length$ &quot;(.+)&quot; HTTP_CONTENT_LENGTH=$1
SetEnvIfNoCase ^Authorization$ &quot;.+username=\&quot;([a-zA-Z0-9]+)\&quot;.+&quot; REMOTE_USER=$1
SetEnvIfNoCase Server_Addr &quot;(.+)&quot; SERVER_ADDR=$1
SetEnvIfNoCase Request_Method &quot;(.+)&quot; REQUEST_METHOD=$1
SetEnvIfNoCase Request_Protocol &quot;(.+)&quot; REQUEST_PROTOCOL=$1
SetEnvIfNoCase Request_URI &quot;(.+)&quot; REQUEST_URI=$1
&nbsp;
RequestHeader set IF_MODIFIED_SINCE &quot;%{HTTP_IF_MODIFIED_SINCE}e&quot;
RequestHeader set IF_NONE_MATCH &quot;%{HTTP_IF_NONE_MATCH}e&quot;
RequestHeader set CACHE_CONTROL &quot;%{HTTP_CACHE_CONTROL}e&quot;
RequestHeader set CONNECTION &quot;%{HTTP_CONNECTION}e&quot;
RequestHeader set KEEP_ALIVE &quot;%{HTTP_KEEP_ALIVE}e&quot;
RequestHeader set AUTHORIZATION &quot;%{HTTP_AUTHORIZATION}e&quot;
RequestHeader set REMOTE_USER &quot;%{REMOTE_USER}e&quot;
RequestHeader set CONTENT_TYPE &quot;%{HTTP_CONTENT_TYPE}e&quot;
RequestHeader set CONTENT_LENGTH &quot;%{HTTP_CONTENT_LENGTH}e&quot;
RequestHeader set SERVER_ADDR &quot;%{SERVER_ADDR}e&quot;
RequestHeader set REQUEST_METHOD &quot;%{REQUEST_METHOD}e&quot;
RequestHeader set REQUEST_PROTOCOL &quot;%{REQUEST_PROTOCOL}e&quot;
RequestHeader set REQUEST_URI &quot;%{REQUEST_URI}e&quot;
&nbsp;
RequestHeader set UNIQUE_ID &quot;%{ENV_UNIQUE_ID}e&quot;
RequestHeader set SCRIPT_URL &quot;%{ENV_SCRIPT_URL}e&quot;
RequestHeader set SCRIPT_URI &quot;%{ENV_SCRIPT_URI}e&quot;
RequestHeader set PATH &quot;%{ENV_PATH}e&quot;
&nbsp;
Options +ExecCGI +FollowSymLinks
&nbsp;
Order Deny,Allow
Deny from All
Allow from 208.113.134.190  64.111.114.111 208.113.134.203 208.113.152.201 env=REDIRECT_STATUS
Satisfy Any
&nbsp;
SecFilterEngine Off</pre>
<h2>More Mod_Security (1)</h2>
<pre>#
# Order Deny,Allow
# First, all Allow directives are evaluated; at least one must match, or the request is rejected.
# Next, all Deny directives are evaluated. If any matches, the request is rejected.
# Last, any requests which do not match an Allow or a Deny directive are denied by default.
#
Order Allow,Deny
Allow from all
Deny from 217.219.
&nbsp;
#Order Deny,Allow
# First, all Deny directives are evaluated; if any match, the request is denied unless it also matches an Allow directive.
# Any requests which do not match any Allow or Deny directives are permitted.
&nbsp;
#SetEnvIf content-type (multipart/form-data)(.*) NEW_CONTENT_TYPE=application/x-www-form-urlencoded$2 OLD_CONTENT_TYPE=$1$2
#RequestHeader set content-type %{NEW_CONTENT_TYPE}e env=NEW_CONTENT_TYPE
SetEnvIfNoCase Content-Type &quot;^multipart/form-data&quot; !MODSEC_NOPOSTBUFFERING
SetEnvIfNoCase Content-Type &quot;^application/x-www-form-urlencoded&quot; !MODSEC_NOPOSTBUFFERING
SetEnv suppress-error-charset
SetEnvIfNoCase Content-Type &quot;^multipart/form-data&quot; !MODSEC_NOPOSTBUFFERING
&nbsp;
SetEnvIf Request_URI &quot;^/(cgi-bin/search\.php|cgi-bin/java\.cgi|wp-admin/.*)&quot; MODSEC_ENABLE=Off
SetEnvIf Request_URI &quot;^/(online-tools/js-compress.*)&quot; &quot;MODSEC_NOPOSTBUFFERING=Do not buffer file uploads&quot;
SetEnvIfNoCase Remote_Addr ^208\.113\.134\.190$ MODSEC_ENABLE=Off
SetEnvIfNoCase Remote_Addr ^64\.111\.114\.111$ MODSEC_ENABLE=Off
&nbsp;
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#
#
# TZ: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
SetEnv TZ America/Indianapolis
&nbsp;
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
SetEnv SERVER_ADMIN webmaster@askapache.com
&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 &quot;EMail&quot; to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
#
ServerSignature Off
&nbsp;
#
# Possible values for the Options directive are &quot;None&quot;, &quot;All&quot;,
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.0/mod/core.html#options
# for more information.
#
Options -Indexes -Includes -ExecCGI -MultiViews
&nbsp;
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
DirectoryIndex 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 &quot;handlers&quot;:
# 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 &quot;ExecCGI&quot; to the &quot;Options&quot; directive.)
#
AddHandler php5-cgi .php .inc
&nbsp;
#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See http://www.iana.org/assignments/character-sets for the
# official list of charset names and their respective RFCs.
#
AddDefaultCharset UTF-8
&nbsp;
#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
#
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.
# Despite the name similarity, the following Add* directives have nothing
# to do with the FancyIndexing customization directives above.
#
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
&nbsp;
#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, &quot;text/plain&quot; is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use &quot;application/octet-stream&quot; instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/html</pre>
<h2>Error Documents</h2>
<pre>#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
#100 Continue
#101 Switching Protocols
#102 Processing
#200 OK
#201 Created
#202 Accepted
#203 Non-Authoritative Information
#204 No Content
#205 Reset Content
#206 Partial Content
#207 Multi-Status
#300 Multiple Choices
#301 Moved Permanently
#302 Found
#303 See Other
#304 Not Modified
#305 Use Proxy
#306 unused
#307 Temporary Redirect
#400 Bad Request
#401 Authorization Required
#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 Large
#415 Unsupported Media Type
#416 Requested Range Not Satisfiable
#417 Expectation Failed
#418 unused
#419 unused
#420 unused
#421 unused
#422 Unprocessable Entity
#423 Locked
#424 Failed Dependency
#425 No code
#426 Upgrade Required
#500 Internal Server Error
#501 Method Not Implemented
#502 Bad Gateway
#503 Service Temporarily Unavailable
#504 Gateway Time-out
#505 HTTP Version Not Supported
#506 Variant Also Negotiates
#507 Insufficient Storage
#508 unused
#509 unused
#510 Not Extended
&nbsp;
#ErrorDocument 100 /e/100_CONTINUE.html
#ErrorDocument 101 /e/101_SWITCHING_PROTOCOLS.html
#ErrorDocument 102 /e/102_PROCESSING.html
&nbsp;
#ErrorDocument 200 /e/200_OK.html
#ErrorDocument 201 /e/201_CREATED.html
#ErrorDocument 202 /e/202_ACCEPTED.html
#ErrorDocument 203 /e/203_NON_AUTHORITATIVE.html
#ErrorDocument 204 /e/204_NO_CONTENT.html
#ErrorDocument 205 /e/205_RESET_CONTENT.html
#ErrorDocument 206 /e/206_PARTIAL_CONTENT.html
#ErrorDocument 207 /e/207_MULTI_STATUS.html
&nbsp;
#ErrorDocument 300 /e/300_MULTIPLE_CHOICES.html
#ErrorDocument 301 /e/301_MOVED_PERMANENTLY.html
#ErrorDocument 302 /e/302_MOVED_TEMPORARILY.html
#ErrorDocument 303 /e/303_SEE_OTHER.html
#ErrorDocument 304 /e/304_NOT_MODIFIED.html
#ErrorDocument 305 /e/305_USE_PROXY.html
#ErrorDocument 307 /e/307_TEMPORARY_REDIRECT.html
&nbsp;
ErrorDocument 400 /e/400_BAD_REQUEST.html
ErrorDocument 401 /e/401_UNAUTHORIZED.html
ErrorDocument 402 /e/402_PAYMENT_REQUIRED.html
ErrorDocument 403 /e/403_FORBIDDEN.html
#ErrorDocument 404 /e/404_NOT_FOUND.html
ErrorDocument 404 /index.php?error=404
ErrorDocument 405 /e/405_METHOD_NOT_ALLOWED.html
ErrorDocument 406 /e/406_NOT_ACCEPTABLE.html
ErrorDocument 407 /e/407_PROXY_AUTHENTICATION_REQUIRED.html
ErrorDocument 408 /e/408_REQUEST_TIME_OUT.html
ErrorDocument 409 /e/409_CONFLICT.html
ErrorDocument 410 /e/410_GONE.html
ErrorDocument 411 /e/411_LENGTH_REQUIRED.html
ErrorDocument 412 /e/412_PRECONDITION_FAILED.html
ErrorDocument 413 /e/413_REQUEST_ENTITY_TOO_LARGE.html
ErrorDocument 414 /e/414_REQUEST_URI_TOO_LARGE.html
ErrorDocument 415 /e/415_UNSUPPORTED_MEDIA_TYPE.html
ErrorDocument 416 /e/416_RANGE_NOT_SATISFIABLE.html
ErrorDocument 417 /e/417_EXPECTATION_FAILED.html
ErrorDocument 422 /e/422_UNPROCESSABLE_ENTITY.html
ErrorDocument 423 /e/423_LOCKED.html
ErrorDocument 424 /e/424_FAILED_DEPENDENCY.html
ErrorDocument 426 /e/426_UPGRADE_REQUIRED.html
ErrorDocument 500 /e/500_INTERNAL_SERVER_ERROR.html
ErrorDocument 501 /e/501_NOT_IMPLEMENTED.html
ErrorDocument 502 /e/502_BAD_GATEWAY.html
ErrorDocument 503 /e/503_SERVICE_UNAVAILABLE.html
ErrorDocument 504 /e/504_GATEWAY_TIME_OUT.html
ErrorDocument 505 /e/505_VERSION_NOT_SUPPORTED.html
ErrorDocument 506 /e/506_VARIANT_ALSO_VARIES.html
ErrorDocument 507 /e/507_INSUFFICIENT_STORAGE.html
ErrorDocument 510 /e/510_NOT_EXTENDED.html</pre>
<h2>Caching</h2>
<p>h2></p>
<pre>#
#  HEADERS and CACHING
#
Header unset Pragma
FileETag None
Header unset ETag
&nbsp;
# 1 YEAR
&lt;FilesMatch &quot;\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$&quot;&gt;
Header unset P3P
Header unset Pragma
FileETag None
Header unset ETag
Header set Cache-Control &quot;public,max-age=29030400&quot;
Header set Expires &quot;Thu, 15 Apr 2010 20:00:00 GMT&quot;
Header unset Last-Modified
&lt;/FilesMatch&gt;
&nbsp;
# 2 HOURS
&lt;FilesMatch &quot;\.(html|htm|xml|txt|xsl|rdf|rss)$&quot;&gt;
&lt;IfModule mod_expires.c&gt;
ExpiresActive On
ExpiresDefault A3600
&lt;/IfModule&gt;
&lt;/FilesMatch&gt;</pre>
<h2>Redirect Hack</h2>
<pre>#Redirect 400 /e/400
#Redirect 401 /e/401
#Redirect 402 /e/402
#Redirect 403 /e/403
Redirect 404 /index.php?error=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 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</pre>
<h2>301 PERMANENT REDIRECTS</h2>
<pre>
#
# Redirect allows you to tell clients about documents which used to exist in
# your server&#039;s namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
#
Redirect 301 /12-lessons-for-those-afraid-of-css.html http://www.askapache.com/css/12-lessons-for-those-afraid-of-css.html
Redirect 301 /2006/htaccess/htaccesselite-ultimate-htaccess-article.html http://www.askapache.com/htaccess/apache-htaccess.html
Redirect 301 /2007/phpbb/sending-post-form-data-with-php-curl.html http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html
Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html
Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html
Redirect 301 /2007/webmaster/php-and-ajax-shell-console.html http://www.askapache.com/tools/php-and-ajax-shell-console.html
Redirect 301 /27-request-methods-for-use-with-apache-and-rewritecond-and-htaccess.html http://www.askapache.com/htaccess/27-request-methods-for-use-with-apache-and-rewritecond-and-htaccess.html
Redirect 301 /404-google-wordpress-plugin.html http://www.askapache.com/seo/404-google-wordpress-plugin.html
Redirect 301 /503-service-temporarily-unavailable.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /Overview-about.rdf http://www.askapache.com/askapache-home.rdf
Redirect 301 /abbr-acronym.html http://www.askapache.com/xhtml/abbr-acronym.html
Redirect 301 /adsense-robots.html http://www.askapache.com/google/adsense-robots.html
Redirect 301 /alexa-toolbar-firefox.html http://www.askapache.com/tools/alexa-toolbar-firefox.html
Redirect 301 /allowing-access-from-1-static-ip-and-deny-the-rest.html http://www.askapache.com/htaccess/apache-htaccess.html
Redirect 301 /anti-virus-spyware-rootkit.html http://www.askapache.com/security/anti-virus-spyware-rootkit.html
Redirect 301 /apache-ssl-in-htaccess-examples.html http://www.askapache.com/htaccess/apache-ssl-in-htaccess-examples.html
Redirect 301 /awk-tutorial.html http://www.askapache.com/awk/awk-tutorial.html
Redirect 301 /best-adsense-optimization.html http://www.askapache.com/wordpress/best-adsense-optimization.html
Redirect 301 /commonly-used-htaccess-code-examples.html http://www.askapache.com/htaccess/commonly-used-htaccess-code-examples.html
Redirect 301 /css-background-image-sprite.html http://www.askapache.com/css/css-background-image-sprite.html
Redirect 301 /css-browser-screenshots.html http://www.askapache.com/tools/css-browser-screenshots.html
Redirect 301 /css-class-example.html http://www.askapache.com/css/css-class-example.html
Redirect 301 /curl-multi-downloads.html http://www.askapache.com/php/curl-multi-downloads.html
Redirect 301 /custom-boot-menu-in-windows-xp.html http://www.askapache.com/windows/custom-boot-menu-in-windows-xp.html
Redirect 301 /donate http://www.dreamhost.com/donate.cgi?id=8261
Redirect 301 /donate/ http://www.dreamhost.com/donate.cgi?id=8261
Redirect 301 /htaccess.txt http://z.askapache.com/p/htaccess.txt
Redirect 301 /htaccess/404-errorpages.html http://www.askapache.com/seo/google-ajax-search-seo-tips.html
Redirect 301 /htaccess/feedsmith http://www.askapache.com/htaccess/feedsmith-htaccess.html
Redirect 301 /htaccess/http-status-codes.html http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html
Redirect 301 /htaccess/instruct-search-engines-to-come-back-to-site-after-you-finish-working-on-it.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /htaccess/speed-up-the-apache-web-server-with-configuration-hacks.html http://www.askapache.com/htaccess/apache-web-server-speed-configuration-hacks.html
Redirect 301 /instruct-search-engines-to-come-back-to-site-after-you-finish-working-on-it.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /security/bypassing-vlan.html http://www.askapache.com/security/hacking-vlan-switched-networks.html
Redirect 301 /security/bypassing-vlanbypassing-vlan.html http://www.askapache.com/security/hacking-vlan-switched-networks.html
Redirect 301 /security/rigging-the-dreamhost-site-of-the-month-contest.html http://www.askapache.com/dreamhost/rigging-the-dreamhost-site-of-the-month-contest.html
Redirect 301 /seo/tailrankcom-robot.html http://www.askapache.com/seo/tailrank-robot.html
Redirect 301 /webmaster/caching-tutorial-for-webmasters.html http://www.askapache.com/htaccess/caching-tutorial-for-webmasters.html
Redirect 301 /webmaster/lft-traceroute-tool.html http://www.askapache.com/tools/lft-traceroute-tool.html</pre>
<h2>301 PERMANENT REDIRECTMATCH</h2>
<pre>#
#  PERMANENT REDIRECTMATCH
#
#RedirectMatch 301 ^/&amp;(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/(.+)\.html/$ http://www.askapache.com/$1.html
RedirectMatch 301 ^/&amp;amp(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/.*feed\.gif$ http://z.askapache.com/feed.gif
RedirectMatch 301 ^/([^/]+)//$ http://www.askapache.com/$1/
RedirectMatch 301 ^/(.+)/htaccesselite-ultimate-htaccess-article.html(.*) http://www.askapache.com/htaccess/apache-htaccess.html
RedirectMatch 301 ^/(.+)\.html/([a-z][a-z])/$ http://www.askapache.com/$1.html
RedirectMatch 301 ^/([\(]+)(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/([^9]*)9O1X.3y(.*)/(.*)$ http://www.askapache.com/$2
RedirectMatch 301 ^/.3y(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/200([0-9])/([0-9])(.*)$ http://www.askapache.com/top-100/
RedirectMatch 301 ^/200([0-9])/([^01])(.*)$ http://www.askapache.com/$2$3
RedirectMatch 301 ^/about/glossary(.*)$ http://www.askapache.com/glossary$1
RedirectMatch 301 ^/apache-speed(.*)$ http://www.askapache.com/htaccess/apache-speed$1
RedirectMatch 301 ^/category/(.+)$ http://www.askapache.com/$1
RedirectMatch 301 ^/docs/(.*)$ http://askapache.info/$1
RedirectMatch 301 ^/htaccess/feedsmith-htaccess(.*) http://www.askapache.com/htaccess/redirecting-wordpress-feeds-to-feedburner.html
RedirectMatch 301 ^/robots-txt(.*)$ http://www.askapache.com/robots.txt
RedirectMatch 301 ^/hosting/?$ http://www.askapache.com/web-hosting/
RedirectMatch 301 ^/.+favicon.ico$ http://www.askapache.com/favicon.ico
#RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://z.askapache.com/uploads/$1
#RedirectMatch 301 ^/z/(.+)$ http://z.askapache.com/$1
#RedirectMatch 301 ^/(z|t|i|j|c|p)/(.*)$ http://z.askapache.com/$1/$2
&nbsp;
#
#  TEMPORARY REDIRECTMATCH
#
RedirectMatch 307 ^/getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash
RedirectMatch 307 ^/dream/?$ http://www.askapache.com/dreamhost/
RedirectMatch 307 ^/(cse|apachecse|apachecsetest|apachesearch)/?$ http://www.google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i
RedirectMatch 307 ^/search/lr-lang(.*)$ http://feeds.askapache.com/apache/htaccess
&nbsp;
#
#  PERMANENT GONE
#
RedirectMatch 410 ^/funny(.*)</pre>
<h2>My Favorite modsec_v1 stuff</h2>
<pre># Pass: Allows request to continue, further filters could still halt request.
# Allow: Allows matching requests through, will not be tested against other filters.
# Deny: Stops the request outright, returns a HTTP 500 error code by default.
# Status: Used to specify an alternate HTTP error code.
# Redirect: Matching requests are redirected to the provided URL.
# Exec: Allows execution of a local system binary or script.
# Log: Logs request only.
# Nolog: Does not log request.
# Chain: Allows you to create list of filters for more granulated security. All filters must be cleared before action is taken with the final filter.
&nbsp;
SecFilterEngine On
SecFilterCheckURLEncoding On
SecFilterCheckUnicodeEncoding Off
SecFilterScanPOST On
&nbsp;
#SecUploadKeepFiles On
#SecUploadDir /home/askapache/sites/askapache.com/logs/sec-upload
#SecUploadApproveScript /home/askapache/sites/askapache.com/htdocs/cgi-bin/check.sh
&nbsp;
#SecRuleEngine On
#SecAuditEngine On
#SecAuditEngine Off
SecAuditEngine RelevantOnly
SecAuditLog /home/askapache/sites/askapache.com/logs/modsec_audit.log
SecFilterDebugLog /home/askapache/sites/askapache.com/logs/modsec_debug.log
SecFilterDebugLevel 1
#SecAuditLogRelevantStatus &quot;^(?:1|2(?!00)|5|4(?!04))&quot;
SecAuditLogRelevantStatus &quot;^(1|2(?!00)|4([0-9](0|1|2|5|6|7|8|9))|5)&quot;
SecFilterForceByteRange 1 255
&nbsp;
#SecFilterInheritance Off
# 0 EMERGENCY - system is unusable
# 1 ALERT - action must be taken immediately
# 2 CRITICAL - critical conditions
# 3 ERROR - error conditions
# 4 WARNING - warning conditions
# 5 NOTICE - normal but significant conditions
# 6 INFO - informational
# 7 DEBUG - debug-level messages
&nbsp;
SecFilterDefaultAction &quot;deny,severity:6,status:403&quot;
&nbsp;
#SecFilterSelective REQUEST_METHOD &quot;POST&quot; &quot;pass,auditlog,severity:6&quot;
SecFilterSelective REQUEST_URI &quot;^/(xmlrpc|wp-comments-post)\.php&quot; &quot;pass,log,auditlog,severity:6&quot;
#SecFilterSelective REMOTE_ADDR ^$ &quot;pass,log,auditlog,severity:6&quot;
#SecFilterSelective REMOTE_ADDR ^203\.221\.91\.20$ &quot;pass,log,auditlog,severity:6&quot;
&nbsp;
#SecFilterSelective REQUEST_URI &quot;^/htaccess.*&quot; &quot;pass,log,auditlog&quot;
#SecFilterSelective REQUEST_URI &quot;^/feed.*&quot; &quot;pass,log,auditlog&quot;
#SecFilterSelective REQUEST_URI &quot;^/.*trackback.*&quot; &quot;pass,log,auditlog&quot;
#SecFilterSelective REQUEST_URI &quot;^/valid.*&quot; &quot;pass,log,auditlog&quot;
&nbsp;
#Enforce proper HTTP requests
SecFilterSelective SERVER_PROTOCOL &quot;!^HTTP/(0\.9|1\.0|1\.1)$&quot; &quot;id:340000,rev:1,severity:6,msg:&#039;Bad HTTP Protocol&#039;&quot;
&nbsp;
# Only accept request encodings we know how to handle
SecFilterSelective REQUEST_METHOD &quot;!^(GET|HEAD|POST)$&quot; &quot;chain,id:340001,rev:1,severity:6,msg:&#039;Restricted HTTP function,status:405&#039;&quot;
SecFilterSelective HTTP_Content-Type &quot;!(^$|^application/x-www-form-urlencoded$|^multipart/form-data)&quot;
&nbsp;
# Require Content-Length to be provided with every POST request
SecFilterSelective REQUEST_METHOD &quot;^POST$&quot; &quot;chain,id:340003,rev:1,severity:6,msg:&#039;Content Length not provided with POST&#039;,status:411&quot;
SecFilterSelective HTTP_Content-Length &quot;^$&quot;
&nbsp;
# Don&#039;t accept transfer encodings we know we don&#039;t handle
# (and you don&#039;t need it anyway)
SecFilterSelective HTTP_Transfer-Encoding &quot;!^$&quot; &quot;id:340004,rev:1,severity:6,msg:&#039;Dis-allowed Transfer Encoding&#039;&quot;
&nbsp;
#Generic rule for allowed characters, adjust for your site before activating
##SecFilterSelective REQUEST_URI &quot;!^[a-zA-Z0-9\.\+\_\/\-\?\=\&amp;\%\#]+$&quot; &quot;chain,id:390002,rev:1,severity:4,msg:&#039;Restricted HTTP character set&#039;&quot;
##SecFilterSelective REQUEST_URI &quot;!^/(openid|wp-admin|wp-includes|wp-content|wp-login.php)&quot;
&nbsp;
#HTTP response splitting generic sigs
#SecFilter &quot;Content-Length\:.*Content-Type\:.*Content-Type\:&quot; &quot;id:340005,rev:1,severity:4,msg:&#039;HTTP response splitting&#039;&quot;
&nbsp;
#HTTP response splitting generic sigs
#SecFilter &quot;Content-Length\:&quot; &quot;chain,id:340006,rev:1,severity:4,msg:&#039;HTTP response splitting&#039;&quot;
#SecFilter &quot;Content-Type\:&quot;
&nbsp;
#catch smuggling attacks
#SecFilter &quot;^(GET|POST).*Host:.*^(GET|POST)&quot;  &quot;id:300012,rev:1,severity:4,msg:&#039;catch smuggling attacks&#039;&quot;
&nbsp;
#XSS insertion into Content-Type
#SecFilterSelective THE_REQUEST &quot;Content-Type\:.*(&lt;[[:space:]]*(script|about|applet|activex|chrome)*&gt;.*(script|about|applet|activex|chrome)[[:space:]]*&gt;|onmouseover=|javascript\:)&quot; &quot;id:300002,rev:1,severity:4,msg:&#039;XSS attack in Content-type header&#039;&quot;
&nbsp;
#Code injection via content length
#SecFilterSelective HTTP_Content-Length|HTTP_USER_AGENT &quot;\;(system|passthru|exec)\(&quot; &quot;id:330003,rev:1,severity:4,msg:&#039;Code Injection in Content-Length header&#039;&quot;
&nbsp;
#Don&#039;t accept chunked encodings modsecurity can not look at these, so this is a hole that can bypass your rules, the rule before this one should cover this, but hey paranoia is cheap
#SecFilterSelective HTTP_Transfer-Encoding &quot;chunked&quot; &quot;id:300003,rev:1,severity:4,msg:&#039;Chunked Transfer Encoding denied&#039;&quot;
&nbsp;
##generic recursion signatures
#SecFilterSelective REQUEST_URI &quot;\.\./\.\./&quot; &quot;id:300004,rev:2,severity:4,msg:&#039;Generic Path Recursion1 denied&#039;&quot;
#SecFilterSelective THE_REQUEST &quot;\.\|\./\.\|\./\.\|&quot; &quot;id:300005,rev:1,severity:4,msg:&#039;Generic Path Recursion2 denied&#039;&quot;
#SecFilterSelective THE_REQUEST &quot;\.\.\./&quot; &quot;id:300006,rev:1,severity:4,msg:&#039;Bogus Path denied&#039;&quot;
&nbsp;
#Generic PHP exploit signatures
#SecFilterSelective REQUEST_URI &quot;&lt;\?php (chr|fwrite|fopen|system|echr|passthru|popen|proc_open|shell_exec|exec|proc_nice|proc_terminate|proc_get_status|proc_close|pfsockopen|leak|apache_child_terminate|posix_kill|posix_mkfifo|posix_setpgid|posix_setsid|posix_setuid|phpinfo)\(.*\)\;&quot; &quot;id:330002,rev:1,severity:4,msg:&#039;Generic PHP exploit pattern denied&#039;&quot;
&nbsp;
#Prevent SQL injection in cookies
##SecFilterSelective COOKIE_VALUES &quot;((select|grant|delete|insert|drop|alter|replace|truncate|update|create|rename|describe)[[:space:]]+[A-Z|a-z|0-9|\*| |\,]+[[:space:]]+(from|into|table|database|index|view)[[:space:]]+[A-Z|a-z|0-9|\*| |\,]|UNION SELECT.*\&#039;.*\&#039;.*,[0-9].*INTO.*FROM)&quot; &quot;id:300011,rev:1,severity:4,msg:&#039;Generic SQL injection in cookie&#039;&quot;
&nbsp;
#Prevent SQL injection in UA
##SecFilterSelective HTTP_USER_AGENT &quot;((select|grant|delete|insert|drop|alter|replace|truncate|update|create|rename|describe)[[:space:]]+[A-Z|a-z|0-9|\*| |\,]+[[:space:]]+(from|into|table|database|index|view)[[:space:]]+[A-Z|a-z|0-9|\*| |\,]|UNION SELECT.*\&#039;.*\&#039;.*,[0-9].*INTO.*FROM)&quot; &quot;id:300012,rev:1,severity:4,msg:&#039;Generic SQL injection in User Agent header&#039;&quot;
&nbsp;
# Generic filter to prevent SQL injection attacks
# Understand that all SQL filters are very limited and are very difficult to prevent false postives and negatives.
# Please report false positives/negatives to mike@gotroot.com
#SecFilter &quot;((select|grant|delete|insert|drop|alter|replace|truncate|update|create|rename|describe)[[:space:]]+[A-Z|a-z|0-9|\*| |\,]+[[:space:]]+(from|into|table|database|index|view)[[:space:]]+[A-Z|a-z|0-9|\*| |\,]|UNION SELECT.*\&#039;.*\&#039;.*,[0-9].*INTO.*FROM)&quot; &quot;id:300013,rev:1,severity:4,msg:&#039;Generic SQL injection protection&#039;&quot;
&nbsp;
#generic XSS PHP attack types
##SecFilterSelective REQUEST_URI &quot;\.php\?&quot; &quot;chain,id:300010,rev:1,severity:4,msg:&#039;Generic PHP XSS exploit pattern denied&#039;&quot;
#SecFilter &quot;(javascript\:/(.*new\x20ActiveXObject.*Sh\.regwrite|.*window\.opener\.document\.body.\innerHTML=window\.opener\.document\.body\.innerHTML\.replace)|onmouseover=\&#039;javascript)&quot;
&nbsp;
#Generic XSS filter
#please report false positives
##SecFilterSelective REQUEST_URI &quot;!/mt\.cgi&quot; &quot;chain,msg:&#039;XSS2&#039;&quot;
#SecFilter &quot;&lt;[[:space:]]*(script|about|applet|activex|chrome)*&gt;.*(script|about|applet|activex|chrome)[[:space:]]*&gt;&quot;
&nbsp;
#XSS in referrer and UA headers
##SecFilterSelective HTTP_REFERER|HTTP_USER_AGENT &quot;&lt;[[:space:]]*(script|about|applet|activex|chrome)*&gt;.*(script|about|applet|activex|chrome)[[:space:]]*&gt;&quot; &quot;msg:&#039;XSS3&#039;&quot;
&nbsp;
#HTTP header PHP code injection attacks
##SecFilterSelective HTTP_CLIENT_IP|HTTP_USER_AGENT|HTTP_Referer &quot;(&lt;\?php|&lt;[[:space:]]?\?[[:space:]]?php|&lt;\? php)&quot; &quot;msg:&#039;PHP1&#039;&quot;
&nbsp;
#Generic PHP remote file injection
##SecFilterSelective REQUEST_URI &quot;!(/do_command)&quot; &quot;chain,msg:&#039;PHP2&#039;&quot;
##SecFilterSelective REQUEST_URI &quot;\.php\?.*=(https?|ftp)\:/.*(cmd|command)=&quot;
&nbsp;
#script, perl, etc. code in HTTP_Referer string
##SecFilterSelective HTTP_Referer &quot;\#\!.*/&quot; &quot;msg:&#039;perl script1&#039;&quot;
&nbsp;
#remote file inclusion generic attack signature
#SecFilterSelective THE_REQUEST  &quot;\.(dat|gif|jpg|png|bmp|txt|vir|dot)\?&quot; &quot;chain,msg:&#039;remote 1&#039;&quot;
#SecFilter &quot;((name|pm_path|pagina|path|include_location|root|page|open)=(http|https|ftp)|(cmd|command|inc)=)&quot;
&nbsp;
#remote file inclusion generic attack signature
#SecFilterSelective THE_REQUEST  &quot;\.(dat|gif|jpg|png|bmp|txt|vir|dot)\?\&amp;(cmd|command|inc|name)=&quot; &quot;msg:&#039;remote2&#039;&quot;
&nbsp;
#remote file inclusion generic attack signature
#SecFilterSelective ARGS  &quot;\.(dat|gif|jpg|png|bmp|txt|vir|dot)&quot; &quot;chain,msg:&#039;file inclusion1&#039;&quot;
#SecFilter &quot;\?\&amp;(cmd|inc|name)=&quot;
&nbsp;
#remote file inclusion generic attack signature
#SecFilterSelective ARGS  &quot;\.(dat|gif|jpg|png|bmp|txt|vir|dot)\?\&amp;(cmd|inc|name)=&quot; &quot;msg:&#039;file inclusion2&#039;&quot;
&nbsp;
#remote file inclusion generic attack signature
#SecFilterSelective REQUEST_URI  &quot;\.php\?.*=(http|https|ftp)\:/.*\?&amp;cmd=&quot; &quot;msg:&#039;file inclusion3&#039;&quot;
&nbsp;
#Bogus file extensions generic signature
#SecFilterSelective THE_REQUEST  &quot;[A-Za-z0-9]\.(gif|jpg|png|bmp)\.txt&quot; &quot;msg:&#039;file extension&#039;&quot;
&nbsp;
#PHP remote path attach generic signature
#SecFilterSelective REQUEST_URI  &quot;\.ph(p(3|4)?).*path=(http|https|ftp)\:/&quot; &quot;msg:&#039;remote path1&#039;&quot;
#SecFilterSelective REQUEST_URI  &quot;\.php.*path=(http|https|ftp)\:/&quot; &quot;msg:&#039;remote path2&#039;&quot;
&nbsp;
#generic php attack sigs
#SecFilterSelective REQUEST_URI &quot;(&amp;(cmd|command)=(id|uname)\x20|cmd\?(cmd|command)=|(spy|cmd|cmd_out|sh)\.(gif|jpg|png|bmp|txt)\?&amp;(cmd|command)=|\.php\?&amp;(cmd|command)=)&quot; &quot;msg:&#039;php attack1&#039;&quot;
&nbsp;
# WEB-MISC apache directory disclosure attempt
#SecFilterSelective THE_REQUEST &quot;////&quot; &quot;msg:&#039;apache directory disclosure&#039;&quot;
&nbsp;
#PHP defenses
##SecFilterSelective ARG_PHPSESSID &quot;!^$&quot; &quot;msg:&#039;something in phpsessid&#039;&quot;
##SecFilterSelective COOKIE_PHPSESSID &quot;!^$&quot; &quot;msg:&#039;something in cookie phpsessid&#039;&quot;
&nbsp;
#PHP defenses
##SecFilterSelective COOKIE_ASKAPACHEID &quot;!^[0-9a-z]*$&quot; &quot;msg:&#039;bad value for cookie&#039;&quot;
&nbsp;
#cross site scripting attempt TYPE + JAVASCRIPT
##SecFilterSelective THE_REQUEST &quot;TYPE\s*=\s*[\&#039;\&quot;]text\/javascript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt STYLE + JAVASCRIPT
##SecFilterSelective THE_REQUEST &quot;TYPE\s*=\s*[\&#039;\&quot;]application\/x-javascript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt STYLE + JSCRIPT
##SecFilterSelective THE_REQUEST &quot;TYPE\s*=\s*[\&#039;\&quot;]text\/jscript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
# cross site scripting attempt STYLE + VBSCRIPT
##SecFilterSelective THE_REQUEST &quot;TYPE\s*=\s*[\&#039;\&quot;]text\/vbscript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt STYLE + VBSCRIPT
##SecFilterSelective THE_REQUEST &quot;TYPE\s*=\s*[\&#039;\&quot;]application\/x-vbscript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt STYLE + ECMACRIPT
##SecFilterSelective THE_REQUEST &quot;TYPE\s*=\s*[\&#039;\&quot;]text\/ecmascript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
# cross site scripting attempt STYLE + EXPRESSION
##SecFilterSelective THE_REQUEST &quot;STYLE[\s]*=[\s]*[^&gt;]expression[\s]*\(&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt STYLE + EXPRESSION
##SecFilterSelective THE_REQUEST &quot;[\s]*expression[\s]*\([^}]}[\s]*&lt;\/STYLE&gt;&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
# cross site scripting attempt using XML
##SecFilterSelective THE_REQUEST &quot;&lt;!\[CDATA\[&lt;\]\]&gt;SCRIPT&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt executing hidden Javascript
##SecFilterSelective THE_REQUEST &quot;eval[\s]*\([\s]*[^\.]\.innerHTML[\s]*\)&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt executing hidden Javascript
##SecFilterSelective THE_REQUEST &quot;window\.execScript[\s]*\(&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting attempt to execute Javascript code
###SecFilterSelective THE_REQUEST &quot;/(((URL|SRC|HREF|LOWSRC)[\s]*=)|(url[\s]*[\(]))[\s]*[\&#039;\&quot;]*javascript[\:]&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#cross site scripting HTML Image tag set to javascript attempt
#SecFilterSelective THE_REQUEST &quot;img src=javascript&quot; &quot;msg:&#039;cross-site1&#039;&quot;
&nbsp;
#Fake image file shell attacvk
#SecFilterSelective HTTP_Content-Type &quot;image/.*&quot; &quot;msg:&#039;image shell 1&#039;&quot;
#SecFilterSelective POST_PAYLOAD &quot;chr\(&quot; &quot;msg:&#039;image shell2&#039;&quot;
&nbsp;
#bogus graphics file
#SecFilterSelective HTTP_Content-Disposition &quot;\.php&quot;  &quot;chain,msg:&#039;bogus graphics&#039;&quot;
#SecFilterSelective HTTP_Content-Type &quot;(image/gif|image/jpg|image/png|image/bmp)&quot;
&nbsp;
# Allow only letters, digits, underscore, and square brackets (for arrays)
# in variable names#
#SecFilterSelective ARGS_NAMES &quot;!^[][a-zA-Z0-9_]+$&quot;
&nbsp;
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-
# reject keywords that appear in POST or GET
#=============================================
SecFilterSignatureAction &quot;nolog,auditlog,deny,severity:6,status:403&quot;
&nbsp;
SecFilterSelective REQUEST_URI  &quot;^/.*/wp-comments-post\.php&quot; &quot;id:50200,msg:&#039;WORDPRESS SPAM bad wp-comments-post location&#039;&quot;
&nbsp;
&lt;Files wp-comments-post.php&gt;
# fail for empty comment fields
SecFilterSelective &quot;ARG_comment_post_ID|ARG_submit&quot; &quot;^$&quot; &quot;id:50300,msg:&#039;WORDPRESS SPAM MISSING comment_post_ID&#039;&quot;
SecFilterSelective &quot;ARG_comment_post_ID&quot; &quot;!^[0-9]{1,6}$&quot; &quot;id:50301,msg:&#039;WORDPRESS SPAM BAD comment_post_ID&#039;&quot;
SecFilterSelective &quot;HTTP_Cookie&quot; &quot;^$&quot; &quot;id:50302,msg:&#039;WORDPRESS SPAM No cookie&#039;&quot;
&nbsp;
##SecFilterSelective &quot;comment_post_DI&quot; &quot;^$&quot; &quot;id:50310,msg:&#039;WORDPRESS SPAM MISSING comment_post_DI&#039;&quot;
##SecFilterSelective &quot;comment_post_DI&quot; &quot;!^[0-9]{1,2}$&quot; &quot;id:50311,msg:&#039;WORDPRESS SPAM MISSING comment_post_DI&#039;&quot;
&lt;/Files&gt;
&lt;pre&gt;
&nbsp;
&lt;h2&gt;MODSEC Continued.. Custom Anti-Spam (WordPress) I made&lt;/h2&gt;
&lt;pre&gt;
SecFilterSignatureAction &quot;nolog,noauditlog,deny,severity:6,redirect:http://www.askapache.com/feed/&quot;
SecFilterSelective ARGS|THE_REQUEST &quot;00bp\.com|360\.yahoo|987mb\.com|Ambien|American airline&quot; &quot;id:50010,msg:&#039;SPAM 10&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;Ativan|Caresoprodol|Darvocet|Ephedra|Ephedrine&quot; &quot;id:50011,msg:&#039;SPAM 11&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;Gambling|Lexapro|Tramadol|Venlafaxine&quot; &quot;id:50012,msg:&#039;SPAM 12&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;\[URL=|abgood|acura|acyclovir|adderall&quot; &quot;id:50013,msg:&#039;SPAM 13&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;adipex|alcohol|alprazolam|amateur|amrit&quot; &quot;id:50014,msg:&#039;SPAM 14&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;anal sex|analfinder|angelina jolie|asshole|axspace\.com&quot; &quot;id:50015,msg:&#039;SPAM 15&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;baccarat|bankrupt|bikini|biotic|black jack|blowjob&quot; &quot;id:50016,msg:&#039;SPAM 16&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;blackjack|blog\.360|brutality|buddhism|butalbital&quot; &quot;id:50017,msg:&#039;SPAM 17&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;cadillac|canalis|card credit|card stud|carisoprodol&quot; &quot;id:50018,msg:&#039;SPAM 18&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;carmen|cash advance|cash credit|casino|catch\.com&quot; &quot;id:50019,msg:&#039;SPAM 19&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;celebrex|celexa|cellulite|cheap|cheerleader&quot; &quot;id:50020,msg:&#039;SPAM 20&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;chevrolet|child abuse|cialis|cigarette|cipro&quot; &quot;id:50021,msg:&#039;SPAM 21&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;citroen|claritin|cleavage|clomid|codeine&quot; &quot;id:50022,msg:&#039;SPAM 22&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;consulting23|craps online|credit card|credit debt|crestor&quot; &quot;id:50023,msg:&#039;SPAM 23&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;dealership|debt free|desnudas|diazepam|dick&quot; &quot;id:50024,msg:&#039;SPAM 24&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;dildo|drugstore|earrings|endometrioma|endowment&quot; &quot;id:50025,msg:&#039;SPAM 25&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;erotic|estrogen|fioricet|francaise|freehost\.com&quot; &quot;id:50026,msg:&#039;SPAM 26&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;freehostia|freemb\.com|fuck|geocities\.com|hacking myspace&quot; &quot;id:50027,msg:&#039;SPAM 27&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;holdem|honda|hotels|hydrocodone|hypnotic&quot; &quot;id:50028,msg:&#039;SPAM 28&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;hyundai|implants|incest|instant approval|insurance&quot; &quot;id:50029,msg:&#039;SPAM 29&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;interracial|jaguar|jenny movie|johanson|kasino&quot; &quot;id:50030,msg:&#039;SPAM 30&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;lesbian|levitra|lipitor|loan|lolita&quot; &quot;id:50031,msg:&#039;SPAM 31&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;lorazepam|lorcet|lyrics|madamic|majorette&quot; &quot;id:50032,msg:&#039;SPAM 32&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;malaria|mastercar|masturbate|masturbation|maturewomen&quot; &quot;id:50033,msg:&#039;SPAM 33&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;mazda|medication|medicine|megsfree5\.com|mercedes&quot; &quot;id:50034,msg:&#039;SPAM 34&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;meridia|metformin|mitsubishi|mortgage|myspace profile&quot; &quot;id:50035,msg:&#039;SPAM 35&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;naked|neocool|nexium|nimire\.com|nissan&quot; &quot;id:50036,msg:&#039;SPAM 36&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;nokia|nude|nudism|nymph|open toe&quot; &quot;id:50037,msg:&#039;SPAM 37&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;oprodol|orgasm|oxycodone|oxycontin|packages&quot; &quot;id:50038,msg:&#039;SPAM 38&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;painrelief|pantyhose|paxil|payday|penis&quot; &quot;id:50039,msg:&#039;SPAM 39&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;percocet|pharmacy|phentermine|phetermine|phpbb_root&quot; &quot;id:50040,msg:&#039;SPAM 40&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;pictaboo|pictorial|pills|pissing|play craps&quot; &quot;id:50041,msg:&#039;SPAM 41&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;playgirl|pocker web|poker|pontiac|poquer&quot; &quot;id:50042,msg:&#039;SPAM 42&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;porn|pounder|prescription|preteen|prevacid&quot; &quot;id:50043,msg:&#039;SPAM 43&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;price1|prilosec|propecia|proza|prozac&quot; &quot;id:50044,msg:&#039;SPAM 44&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;puddled|pussy|refinance|rentals|replica&quot; &quot;id:50045,msg:&#039;SPAM 45&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;ringtones|roulette|screensaver|seduced|sexual&quot; &quot;id:50046,msg:&#039;SPAM 46&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;sexy|shemale|shiloh|singulair|site-host&quot; &quot;id:50047,msg:&#039;SPAM 47&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;slot machine|slot maschine|slots machine|solpip\.com|soma&quot; &quot;id:50048,msg:&#039;SPAM 48&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;sperm|starlets|supplier|suzuki|tadalafil&quot; &quot;id:50049,msg:&#039;SPAM 49&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;toyota|tylenol|ultram|valium|viagra&quot; &quot;id:50050,msg:&#039;SPAM 50&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;vigora|vioxx|wallpaper|warez|webcam&quot; &quot;id:50051,msg:&#039;SPAM 51&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;webpages\.com|wellbutrin|whitesluts|wholesale|whore&quot; &quot;id:50052,msg:&#039;SPAM 52&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;windshield|xanax|xenical|y lohan|yourgirls&quot; &quot;id:50053,msg:&#039;SPAM 53&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;youtube\.com|zantac|sex offenders|hotgay|Zoloft|celtic women&quot; &quot;id:50054,msg:&#039;SPAM 54&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;dollhouse|freehot|kardashian|oralsex&quot; &quot;id:50055,msg:&#039;SPAM 55&#039;
SecFilterSelective ARGS|THE_REQUEST &quot;freeimghost&quot; &quot;id:50056,msg:&#039;SPAM 56&#039;</pre>
<h2>Unreleased AskApache Lightning code - caching plugin for WordPress</h2>
<pre>RewriteEngine On
RewriteBase /
&nbsp;
RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|test/).* [NC,OR]
RewriteCond %{ENV:REDIRECT_STATUS} =200
RewriteRule .* - [L]
&nbsp;
RewriteCond %{HTTP_HOST} !=www.askapache.com
RewriteCond %{HTTP_HOST} !=z.askapache.com
RewriteRule .? http://www.askapache.com%{REQUEST_URI}%{QUERY_STRING} [R=301,L]
&nbsp;
#RewriteCond %{HTTPS} =on
#RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /(wp-login.php|wp-admin)(.*)\ HTTP/ [NC]
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC]
#RewriteRule .* http://www.askapache.com/$1 [R=301,L]
&nbsp;
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)%20(.+)\ HTTP/ [NC]
RewriteRule .* http://www.askapache.com/%1-%2 [R=301,L]
&nbsp;
RewriteCond %{THE_REQUEST} ^GET\ /valid-html/.*\ HTTP/ [NC]
RewriteCond %{HTTP_REFERER} ^https?://www.askapache.com(.+).*$ [NC]
RewriteRule .* http://validator.w3.org/check?uri=http://www.askapache.com%1;ss=1;outline=1;debug [R=307,L,NE]
&nbsp;
RewriteCond %{THE_REQUEST} ^GET\ /valid-css/.*\ HTTP/ [NC]
RewriteRule .* http://jigsaw.w3.org/css-validator/validator?uri=z.askapache.com/z/c/apache-10.css [R=301,L]
&nbsp;
RewriteCond %{THE_REQUEST} ^GET\ /search/.*\ HTTP/ [NC]
RewriteCond %{QUERY_STRING} ^s=(.+)$ [NC]
RewriteRule .* http://www.askapache.com/search/%1? [R=302,L]
&nbsp;
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/X%{REQUEST_URI}index.html -f
RewriteRule ^(.*)$ /X%{REQUEST_URI}index.html [L]
&nbsp;
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/X%{REQUEST_URI} -f
RewriteRule ^(.*)$ /X%{REQUEST_URI} [L]</pre>
<h2>Passing Parameters to CGI through HTTP Headers</h2>
<p>This deserves a note.. this trick lets you bypass so many hosting environment restrictions it&#8217;s not even funny&#8230; like you can run bash as your webserver instead of apache!  (kinda&#8230;)</p>
<pre>RewriteCond %{REQUEST_URI} ^/cgi-bin/(hash|java)\.cgi$ [NC]
RewriteCond %{HTTP:P3P} ^(([^:]+):(.+))$ [NC]
RewriteRule .* - [E=HTTP_JS:%{HTTP:P3P},E=HTTP_US:%2,E=HTTP_PA:%3]</pre>
<h2>Redirect to FeedBurner</h2>
<p>Yes.. I was the first to do this (parse the real rewrites internally in wordpress for no bypassing possibilities)&#8230; </p>
<pre>#RewriteCond %{REQUEST_URI} ^/feed/.*?$ [NC,OR]
#RewriteCond %{HTTP_REFERER} ^https?://www.askapache.com/wp-admin(.+).*$ [NC]
RewriteCond %{HTTP_USER_AGENT} FeedBurner [NC]
RewriteRule .* - [S=1]
&nbsp;
RewriteCond %{REQUEST_URI} ^/(feed|rdf|rss|rss2|atom).* [NC,OR]
RewriteCond %{REQUEST_URI} ^/wp-(feed|rdf|rss|rss2|atom).* [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^.*/(wp-atom|wp-feed|wp-rdf|wp-rss|wp-rss2)\.php$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^.*/wp-includes/feed[^\.]*\.php$ [NC,OR]
RewriteCond %{QUERY_STRING} .*(feed|rdf|rss|rss2|atom).* [NC]
RewriteRule .* http://feeds.askapache.com/apache/htaccess? [R=302,L]</pre>
<h2>More Unreleased Caching Tests</h2>
<pre># +ASKAPACHE CRAZYCACHE 2.3
#######################################################
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
# +ACACHE RULES
# +RULE
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ //?(.+)\.rdf\ HTTP/ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-cache/%2.html/index.rdf -f
RewriteRule ^(.+)\.rdf$ /wp-cache/%2.html/index.rdf [L,S=3]
&nbsp;
RewriteCond %{QUERY_STRING} !^.*cacheit.* [NC]
#RewriteCond %{HTTP_USER_AGENT} W3C_Validator [OR,NC]
#RewriteCond %{REMOTE_ADDR} = [OR]
&nbsp;
RewriteCond %{REQUEST_METHOD} =POST [OR]
RewriteCond %{THE_REQUEST} ^$ [OR]
RewriteCond %{QUERY_STRING} nocache [OR]
RewriteCond %{REMOTE_ADDR} = [OR]
RewriteCond %{HTTP_COOKIE} ^.*wordpress_logged_in_.*$ [NC]
RewriteRule .+ - [S=2]
&nbsp;
RewriteCond %{DOCUMENT_ROOT}/wp-cache%{REQUEST_URI} !-d
RewriteRule .+ - [S=1]
&nbsp;
RewriteCond %{DOCUMENT_ROOT}/wp-cache%{REQUEST_URI}/index.html -f
RewriteRule .+ /wp-cache%{REQUEST_URI}/index.html [L]
# -RULE
# -ACACHE RULES
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
#######################################################
# -ASKAPACHE CRAZYCACHE 2.3
&nbsp;
# +ASKAPACHE CRAZYCACHE 2.3
#######################################################
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
# +ACACHE RULES
# +RULE
FileETag None
AddOutputFilterByType DEFLATE text/html
&nbsp;
AddType &#039;text/html; charset=UTF-8&#039; .html
&nbsp;
Header set P3P &quot;policyref=\&quot;http://www.askapache.com/w3c/p3p.xml\&quot;&quot;
Header set X-Pingback &quot;http://www.askapache.com/xmlrpc.php&quot;
Header set Content-Language &quot;en-US&quot;
Header set Vary &quot;Accept-Encoding,Accept&quot;
&nbsp;
&lt;IfModule mod_expires.c&gt;
ExpiresActive On
ExpiresDefault M7200
&lt;/IfModule&gt;
# -RULE
# -ACACHE RULES
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
#               __                          __
#   ____ ______/ /______ _____  ____ ______/ /_  ___
#  / __ `/ ___/ //_/ __ `/ __ \/ __ `/ ___/ __ \/ _ \
# / /_/ (__  ) ,&lt; / /_/ / /_/ / /_/ / /__/ / / /  __/
# \__,_/____/_/|_|\__,_/ .___/\__,_/\___/_/ /_/\___/
#                     /_/
#######################################################
# -ASKAPACHE CRAZYCACHE 2.3
&nbsp;
Options +IndexesOptions +FollowSymLinks
AddHandler application/x-httpd-php .php
&nbsp;
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !^tyy+$ [NC]
RewriteCond %{REMOTE_USER} ^(.+)$
RewriteRule ^(.*)$ $1/-%1 [R=302,L]
Options +FollowSymLinks
DirectoryIndex index.php
ErrorDocument 404 /cgi-bin/pro/index.php
&nbsp;
AuthName &quot;Protection&quot;
AuthUserFile /home/askapache/sites/askapache.com/.htpasswda1
AuthGroupFile /dev/null
AuthType Basic
Require valid-user
Satisfy Any
&nbsp;
&lt;IfModule mod_security.c&gt;
SecFilterEngine Off
&lt;/IfModule&gt;
Options +ExecCGI -Indexes -Includes +FollowSymLinks
Order Deny,Allow
Deny from All
Allow from 208.113.134.190 64.111.114.111  env=REDIRECT_STATUS
&nbsp;
#SetEnvIf Remote_Addr ^$ MODSEC_ENABLE=Off
#SetEnvIf Server_Addr ^$ MODSEC_ENABLE=Off
#SetEnvIf Remote_Addr ^({SERVER_ADDR}e)$ GOOD=$1
#SetEnvIf Server_Addr GOOD R</pre>
<h2>Default HTACCESS</h2>
<pre>#
# Directives controlling the display of server-generated directory listings.
#
# Required modules: mod_autoindex, mod_alias
#
# To see the listing of a directory, the Options directive for the
# directory must include &quot;Indexes&quot;, and the directory must not contain
# a file matching those listed in the DirectoryIndex directive.
#
Options +Indexes +MultiViews -ExecCGI +FollowSymLinks
DirectoryIndex index.html
&nbsp;
#
#
# IndexOptions: Controls the appearance of server-generated directory
# listings.
#
IndexOptions FancyIndexing IconHeight=22 IconWidth=20 IgnoreClient NameWidth=* DescriptionWidth=* ScanHTMLTitles SuppressLastModified XHTML FoldersFirst SuppressHTMLPreamble
&nbsp;
#
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions.  These are only displayed for
# FancyIndexed directories.
#
&nbsp;
AddIconByEncoding (CMP,http://z.askapache.com/i/s/compressed.gif) x-compress x-gzip
&nbsp;
AddIconByType (IMG,http://z.askapache.com/i/s/image.gif) image/*
AddIconByType (SND,http://z.askapache.com/i/s/sound2.gif) audio/*
AddIconByType (TXT,http://z.askapache.com/i/s/text.gif) text/*
AddIconByType (VID,http://z.askapache.com/i/s/movie.gif) video/*
&nbsp;
AddIcon http://z.askapache.com/i/s/hand.right.gif README
AddIcon http://z.askapache.com/i/s/folder.gif ^^DIRECTORY^^
AddIcon http://z.askapache.com/i/s/dir.png ^^DIRECTORY^^
AddIcon http://z.askapache.com/i/s/blank.gif ^^BLANKICON^^
AddDescription &quot;100 Continue&quot; 100* 100/index.html
AddDescription &quot;101 Switching Protocols&quot; 101* 101/index.html
AddDescription &quot;102 Processing&quot; 102* 102/index.html
AddDescription &quot;200 OK&quot; 200* 200/index.html
AddDescription &quot;201 Created&quot; 201* 201/index.html
AddDescription &quot;202 Accepted&quot; 202* 202/index.html
AddDescription &quot;203 Non-Authoritative Information&quot; 203* 203/index.html
AddDescription &quot;204 No Content&quot; 204* 204/index.html
AddDescription &quot;205 Reset Content&quot; 205* 205/index.html
AddDescription &quot;206 Partial Content&quot; 206* 206/index.html
AddDescription &quot;207 Multi-Status&quot; 207* 207/index.html
AddDescription &quot;300 Multiple Choices&quot; 300* 300/index.html
AddDescription &quot;301 Moved Permanently&quot; 301* 301/index.html
AddDescription &quot;302 Found&quot; 302* 302/index.html
AddDescription &quot;303 See Other&quot; 303* 303/index.html
AddDescription &quot;304 Not Modified&quot; 304* 304/index.html
AddDescription &quot;305 Use Proxy&quot; 305* 305/index.html
AddDescription &quot;306 unused&quot; 306* 306/index.html
AddDescription &quot;307 Temporary Redirect&quot; 307* 307/index.html
AddDescription &quot;400 Bad Request&quot; 400* 400/index.html
AddDescription &quot;401 Authorization Required&quot; 401* 401/index.html
AddDescription &quot;402 Payment Required&quot; 402* 402/index.html
AddDescription &quot;403 Forbidden&quot; 403* 403/index.html
AddDescription &quot;404 Not Found&quot; 404* 404/index.html
AddDescription &quot;405 Method Not Allowed&quot; 405* 405/index.html
AddDescription &quot;406 Not Acceptable&quot; 406* 406/index.html
AddDescription &quot;407 Proxy Authentication Required&quot; 407* 407/index.html
AddDescription &quot;408 Request Time-out&quot; 408* 408/index.html
AddDescription &quot;409 Conflict&quot; 409* 409/index.html
AddDescription &quot;410 Gone&quot; 410* 410/index.html
AddDescription &quot;411 Length Required&quot; 411* 411/index.html
AddDescription &quot;412 Precondition Failed&quot; 412* 412/index.html
AddDescription &quot;413 Request Entity Too Large&quot; 413* 413/index.html
AddDescription &quot;414 Request-URI Too Large&quot; 414* 414/index.html
AddDescription &quot;415 Unsupported Media Type&quot; 415* 415/index.html
AddDescription &quot;416 Requested Range Not Satisfiable&quot; 416* 416/index.html
AddDescription &quot;417 Expectation Failed&quot; 417* 417/index.html
AddDescription &quot;418 unused&quot; 418* 418/index.html
AddDescription &quot;419 unused&quot; 419* 419/index.html
AddDescription &quot;420 unused&quot; 420* 420/index.html
AddDescription &quot;421 unused&quot; 421* 421/index.html
AddDescription &quot;422 Unprocessable Entity&quot; 422* 422/index.html
AddDescription &quot;423 Locked&quot; 423* 423/index.html
AddDescription &quot;424 Failed Dependency&quot; 424* 424/index.html
AddDescription &quot;425 No code&quot; 425* 425/index.html
AddDescription &quot;426 Upgrade Required&quot; 426* 426/index.html
AddDescription &quot;500 Internal Server Error&quot; 500* 500/index.html
AddDescription &quot;501 Method Not Implemented&quot; 501* 501/index.html
AddDescription &quot;502 Bad Gateway&quot; 502* 502/index.html
AddDescription &quot;503 Service Temporarily Unavailable&quot; 503* 503/index.html
AddDescription &quot;504 Gateway Time-out&quot; 504* 504/index.html
AddDescription &quot;505 HTTP Version Not Supported&quot; 505* 505/index.html
AddDescription &quot;506 Variant Also Negotiates&quot; 506* 506/index.html
AddDescription &quot;507 Insufficient Storage&quot; 507* 507/index.html
AddDescription &quot;508 unused&quot; 508* 508/index.html
AddDescription &quot;509 unused&quot; 509* 509/index.html
AddDescription &quot;510 Not Extended&quot; 510* 510/index.html
AddDescription &quot;.htaccess ErrorDocuments&quot; *
&nbsp;
#
# HeaderName is the name of a file which should be prepended to
# directory indexes.
ReadmeName /X/error/README.html
HeaderName /X/error/HEADER.html
&nbsp;
# DefaultIcon is which icon to show for where none is explicitly set.
DefaultIcon http://z.askapache.com/i/s/generic.gif</pre>
<h2>Ok I&#8217;m done commenting..</h2>
<pre>#
# IndexIgnore is a set of filenames which directory indexing should ignore
# and not include in the listing.  Shell-style wildcarding is permitted.
#
IndexIgnore .??*  *_notes *~
RewriteEngine On
RewriteCond %{HTTPS} !=on [NC]
RewriteRule .* https://www.askapache.com%{REQUEST_URI}
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},E=REMOTE_USER:%{HTTP:Authorization}]
&nbsp;
#RewriteCond %{QUERY_STRING} openid.mode=authorize
#RewriteCond %{REQUEST_URI} ^/openid.*$ [NC]
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},E=REMOTE_USER:%{HTTP:Authorization}]
Options +FollowSymLinks
DirectoryIndex index.html
&nbsp;
#SetEnvIfNoCase ^Cookie$ &quot;(.*)&quot; HTTP_MY_COOKIE=$1
#SetEnvIfNoCase Remote_Addr &quot;(.*)&quot; HTTP_MY_REMOTE_ADDR=$1
ExpiresActive Off
FileETag None
Header unset Connection
Header set Connection &quot;close&quot;
Header unset Last-Modified
Header unset ETag
Header unset Accept-Ranges
Header unset Vary
Header unset Content-Type
Header unset X-Pingback
Header unset P3P
#Header add RouterBits &quot;%D %t&quot;
#Header add Location &quot;http://www.askapache.com/feed/&quot;
#Header add Found &quot;http://askapache.com/feed/&quot;
#Header add Content-Location &quot;http://www.askapache.com/feed/&quot;
#Header add Refresh &quot;http://www.askapache.com/feed/&quot;
#Header set Hi &quot;%{HTTP_MY_REMOTE_ADDR}e&quot;
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#
#
# TZ: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
SetEnv TZ America/Indianapolis
&nbsp;
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
SetEnv SERVER_ADMIN webmaster@askapache.com
&nbsp;
#
# Possible values for the Options directive are &quot;None&quot;, &quot;All&quot;,
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.0/mod/core.html#options
# for more information.
#
Options  +FollowSymLinks -ExecCGI -Indexes -Includes -MultiViews
&nbsp;
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
DirectoryIndex index.html index.php /index.php
&nbsp;
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
&lt;FilesMatch &quot;^\.ht&quot;&gt;
    Order allow,deny
    Deny from all
  Satisfy All
&lt;/FilesMatch&gt;
&nbsp;
#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, &quot;text/plain&quot; is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use &quot;application/octet-stream&quot; instead to
# keep browsers from trying to display binary files as though they are
# text.
#
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 &quot;EMail&quot; to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
#
ServerSignature Off
&nbsp;
##############################################
#           HEADERS and CACHING              #
##############################################
Header unset Pragma
Header unset Last-Modified
FileETag None
&nbsp;
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 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
&nbsp;

#
# Redirect allows you to tell clients about documents which used to exist in
# your server&#039;s namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
##############################################
#          PERMANENT REDIRECTS               #
##############################################
Redirect 301 /12-lessons-for-those-afraid-of-css.html http://www.askapache.com/css/12-lessons-for-those-afraid-of-css.html
Redirect 301 /2006/htaccess/htaccesselite-ultimate-htaccess-article.html http://www.askapache.com/htaccess/apache-htaccess.html
Redirect 301 /2007/phpbb/sending-post-form-data-with-php-curl.html http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html
Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html
Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html
Redirect 301 /2007/webmaster/php-and-ajax-shell-console.html http://www.askapache.com/tools/php-and-ajax-shell-console.html
Redirect 301 /27-request-methods-for-use-with-apache-and-rewritecond-and-htaccess.html http://www.askapache.com/htaccess/27-request-methods-for-use-with-apache-and-rewritecond-and-htaccess.html
Redirect 301 /404-google-wordpress-plugin.html http://www.askapache.com/seo/404-google-wordpress-plugin.html
Redirect 301 /503-service-temporarily-unavailable.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /Overview-about.rdf http://www.askapache.com/askapache-home.rdf
Redirect 301 /abbr-acronym.html http://www.askapache.com/xhtml/abbr-acronym.html
Redirect 301 /adsense-robots.html http://www.askapache.com/google/adsense-robots.html
Redirect 301 /alexa-toolbar-firefox.html http://www.askapache.com/tools/alexa-toolbar-firefox.html
Redirect 301 /allowing-access-from-1-static-ip-and-deny-the-rest.html http://www.askapache.com/htaccess/apache-htaccess.html
Redirect 301 /anti-virus-spyware-rootkit.html http://www.askapache.com/security/anti-virus-spyware-rootkit.html
Redirect 301 /apache-ssl-in-htaccess-examples.html http://www.askapache.com/htaccess/apache-ssl-in-htaccess-examples.html
Redirect 301 /awk-tutorial.html http://www.askapache.com/awk/awk-tutorial.html
Redirect 301 /best-adsense-optimization.html http://www.askapache.com/wordpress/best-adsense-optimization.html
Redirect 301 /commonly-used-htaccess-code-examples.html http://www.askapache.com/htaccess/commonly-used-htaccess-code-examples.html
Redirect 301 /css-background-image-sprite.html http://www.askapache.com/css/css-background-image-sprite.html
Redirect 301 /css-browser-screenshots.html http://www.askapache.com/tools/css-browser-screenshots.html
Redirect 301 /css-class-example.html http://www.askapache.com/css/css-class-example.html
Redirect 301 /curl-multi-downloads.html http://www.askapache.com/php/curl-multi-downloads.html
Redirect 301 /custom-boot-menu-in-windows-xp.html http://www.askapache.com/windows/custom-boot-menu-in-windows-xp.html
Redirect 301 /donate http://www.dreamhost.com/donate.cgi?id=8261
Redirect 301 /donate/ http://www.dreamhost.com/donate.cgi?id=8261
Redirect 301 /htaccess.txt http://z.askapache.com/p/htaccess.txt
Redirect 301 /htaccess/404-errorpages.html http://www.askapache.com/seo/google-ajax-search-seo-tips.html
Redirect 301 /htaccess/feedsmith http://www.askapache.com/htaccess/feedsmith-htaccess.html
Redirect 301 /htaccess/http-status-codes.html http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html
Redirect 301 /htaccess/instruct-search-engines-to-come-back-to-site-after-you-finish-working-on-it.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /htaccess/speed-up-the-apache-web-server-with-configuration-hacks.html http://www.askapache.com/htaccess/apache-web-server-speed-configuration-hacks.html
Redirect 301 /instruct-search-engines-to-come-back-to-site-after-you-finish-working-on-it.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /security/bypassing-vlan.html http://www.askapache.com/security/hacking-vlan-switched-networks.html
Redirect 301 /security/bypassing-vlanbypassing-vlan.html http://www.askapache.com/security/hacking-vlan-switched-networks.html
Redirect 301 /security/rigging-the-dreamhost-site-of-the-month-contest.html http://www.askapache.com/dreamhost/rigging-the-dreamhost-site-of-the-month-contest.html
Redirect 301 /seo/tailrankcom-robot.html http://www.askapache.com/seo/tailrank-robot.html
Redirect 301 /webmaster/caching-tutorial-for-webmasters.html http://www.askapache.com/htaccess/caching-tutorial-for-webmasters.html
Redirect 301 /webmaster/lft-traceroute-tool.html http://www.askapache.com/tools/lft-traceroute-tool.html
&nbsp;
##############################################
#          PERMANENT REDIRECTMATCH           #
##############################################
#RedirectMatch 301 ^/&amp;(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/&amp;amp(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/([^/]+)//$ http://www.askapache.com/$1/
RedirectMatch 301 ^/(.+)/htaccesselite-ultimate-htaccess-article.html(.*) http://www.askapache.com/htaccess/apache-htaccess.html
RedirectMatch 301 ^/(.+)\.html/([a-z][a-z])/$ http://www.askapache.com/$1.html
RedirectMatch 301 ^/([\(]+)(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/([^9]*)9O1X.3y(.*)/(.*)$ http://www.askapache.com/$2
RedirectMatch 301 ^/.3y(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/200([0-9])/([0-9])(.*)$ http://www.askapache.com/top-100/
RedirectMatch 301 ^/200([0-9])/([^01])(.*)$ http://www.askapache.com/$2$3
RedirectMatch 301 ^/about/glossary(.*)$ http://www.askapache.com/glossary$1
RedirectMatch 301 ^/apache-speed(.*)$ http://www.askapache.com/htaccess/apache-speed$1
RedirectMatch 301 ^/category/(.+)$ http://www.askapache.com/$1
RedirectMatch 301 ^/docs/(.*)$ http://askapache.info/$1
RedirectMatch 301 ^/htaccess/feedsmith-htaccess(.*) http://www.askapache.com/htaccess/redirecting-wordpress-feeds-to-feedburner.html
RedirectMatch 301 ^/robots-txt(.*)$ http://www.askapache.com/robots.txt
#RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://z.askapache.com/uploads/$1
RedirectMatch 301 ^/z/(.+)$ http://z.askapache.com/$1
RedirectMatch 301 ^/(z|t|i|j|c|p)/(.*)$ http://z.askapache.com/$1/$2
RedirectMatch 301 ^/hosting/?$ http://www.askapache.com/web-hosting/
&nbsp;
##############################################
#          TEMPORARY REDIRECTMATCH           #
##############################################
RedirectMatch 307 ^/getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash
RedirectMatch 307 ^/dream/?$ http://www.askapache.com/dreamhost/
RedirectMatch 307 ^/(cse|apachecse|apachecsetest|apachesearch)/?$ http://www.google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i
&nbsp;

#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See http://www.iana.org/assignments/character-sets for the
# official list of charset names and their respective RFCs.
#
AddDefaultCharset UTF-8
&nbsp;
#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
#
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.
# Despite the name similarity, the following Add* directives have nothing
# to do with the FancyIndexing customization directives above.
#
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
&nbsp;
#
# AddHandler allows you to map certain file extensions to &quot;handlers&quot;:
# 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 &quot;ExecCGI&quot; to the &quot;Options&quot; directive.)
#
AddHandler php-cgi .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 php-cgi /cgi-bin/php.cgi
&nbsp;
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
#100 Continue
#101 Switching Protocols
#102 Processing
#200 OK
#201 Created
#202 Accepted
#203 Non-Authoritative Information
#204 No Content
#205 Reset Content
#206 Partial Content
#207 Multi-Status
#300 Multiple Choices
#301 Moved Permanently
#302 Found
#303 See Other
#304 Not Modified
#305 Use Proxy
#306 unused
#307 Temporary Redirect
#400 Bad Request
#401 Authorization Required
#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 Large
#415 Unsupported Media Type
#416 Requested Range Not Satisfiable
#417 Expectation Failed
#418 unused
#419 unused
#420 unused
#421 unused
#422 Unprocessable Entity
#423 Locked
#424 Failed Dependency
#425 No code
#426 Upgrade Required
#500 Internal Server Error
#501 Method Not Implemented
#502 Bad Gateway
#503 Service Temporarily Unavailable
#504 Gateway Time-out
#505 HTTP Version Not Supported
#506 Variant Also Negotiates
#507 Insufficient Storage
#508 unused
#509 unused
#510 Not Extended
&nbsp;
#ErrorDocument 100 /X/err/1/HTTP_CONTINUE.html
#ErrorDocument 101 /X/err/1/HTTP_SWITCHING_PROTOCOLS.html
#ErrorDocument 102 /X/err/1/HTTP_PROCESSING.html
&nbsp;
#ErrorDocument 200 /X/err/2/HTTP_OK.html
#ErrorDocument 201 /X/err/2/HTTP_CREATED.html
#ErrorDocument 202 /X/err/2/HTTP_ACCEPTED.html
#ErrorDocument 203 /X/err/2/HTTP_NON_AUTHORITATIVE.html
#ErrorDocument 204 /X/err/2/HTTP_NO_CONTENT.html
#ErrorDocument 205 /X/err/2/HTTP_RESET_CONTENT.html
#ErrorDocument 206 /X/err/2/HTTP_PARTIAL_CONTENT.html
#ErrorDocument 207 /X/err/2/HTTP_MULTI_STATUS.html
&nbsp;
#ErrorDocument 300 /X/err/HTTP_MULTIPLE_CHOICES.html
#ErrorDocument 301 /X/err/HTTP_MOVED_PERMANENTLY.html
#ErrorDocument 302 /X/err/HTTP_MOVED_TEMPORARILY.html
#ErrorDocument 303 /X/err/HTTP_SEE_OTHER.html
#ErrorDocument 304 /X/err/HTTP_NOT_MODIFIED.html
#ErrorDocument 305 /X/err/HTTP_USE_PROXY.html
#ErrorDocument 307 /X/err/HTTP_TEMPORARY_REDIRECT.html
#ErrorDocument 404 /X/err/HTTP_NOT_FOUND.html
&nbsp;
ErrorDocument 400 /X/err/4/HTTP_BAD_REQUEST.html
ErrorDocument 401 /X/err/4/HTTP_UNAUTHORIZED.html
ErrorDocument 402 /X/err/4/HTTP_PAYMENT_REQUIRED.html
ErrorDocument 403 /X/err/4/HTTP_FORBIDDEN.html
ErrorDocument 405 /X/err/4/HTTP_METHOD_NOT_ALLOWED.html
ErrorDocument 406 /X/err/4/HTTP_NOT_ACCEPTABLE.html
ErrorDocument 407 /X/err/4/HTTP_PROXY_AUTHENTICATION_REQUIRED.html
ErrorDocument 408 /X/err/4/HTTP_REQUEST_TIME_OUT.html
ErrorDocument 409 /X/err/4/HTTP_CONFLICT.html
ErrorDocument 410 /X/err/4/HTTP_GONE.html
ErrorDocument 411 /X/err/4/HTTP_LENGTH_REQUIRED.html
ErrorDocument 412 /X/err/4/HTTP_PRECONDITION_FAILED.html
ErrorDocument 413 /X/err/4/HTTP_REQUEST_ENTITY_TOO_LARGE.html
ErrorDocument 414 /X/err/4/HTTP_REQUEST_URI_TOO_LARGE.html
ErrorDocument 415 /X/err/4/TTP_UNSUPPORTED_MEDIA_TYPE.html
ErrorDocument 416 /X/err/4/HTTP_RANGE_NOT_SATISFIABLE.html
ErrorDocument 417 /X/err/4/HTTP_EXPECTATION_FAILED.html
ErrorDocument 422 /X/err/4/HTTP_UNPROCESSABLE_ENTITY.html
ErrorDocument 423 /X/err/4/HTTP_LOCKED.html
ErrorDocument 424 /X/err/4/HTTP_FAILED_DEPENDENCY.html
ErrorDocument 426 /X/err/4/HTTP_UPGRADE_REQUIRED.html
&nbsp;
ErrorDocument 500 /X/err/5/HTTP_INTERNAL_SERVER_ERROR.html
ErrorDocument 501 /X/err/5/HTTP_NOT_IMPLEMENTED.html
ErrorDocument 502 /X/err/5/HTTP_BAD_GATEWAY.html
ErrorDocument 503 /X/err/5/HTTP_SERVICE_UNAVAILABLE.html
ErrorDocument 504 /X/err/5/HTTP_GATEWAY_TIME_OUT.html
ErrorDocument 505 /X/err/5/HTTP_VERSION_NOT_SUPPORTED.html
ErrorDocument 506 /X/err/5/HTTP_VARIANT_ALSO_VARIES.html
ErrorDocument 507 /X/err/5/HTTP_INSUFFICIENT_STORAGE.html
ErrorDocument 510 /X/err/5/HTTP_NOT_EXTENDED.html
ErrorDocument 404 /index.php?error=404
&nbsp;
# 1 YEAR
&lt;FilesMatch &quot;\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$&quot;&gt;
Header unset P3P
Header set Cache-Control &quot;public&quot;
Header set Expires &quot;Thu, 15 Apr 2010 20:00:00 GMT&quot;
&lt;/FilesMatch&gt;
&nbsp;
# 2 HOURS
&lt;FilesMatch &quot;\.(html|htm|xml|txt|xsl)$&quot;&gt;
&lt;IfModule mod_expires.c&gt;
ExpiresActive On
ExpiresDefault A3600
&lt;/IfModule&gt;
&lt;/FilesMatch&gt;
&nbsp;
RewriteEngine On
RewriteBase /
&nbsp;
RewriteCond %{ENV:REDIRECT_STATUS} =200
RewriteRule .* - [L]
&nbsp;
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD) [OR]
#RewriteCond %{QUERY_STRING} !^$ [OR]
RewriteCond %{HTTP_COOKIE} ^.*(comment_author_|wordpress|wp-postpass_).*$ [NC]
RewriteRule ^(.*)$ - [S=6]
&nbsp;
RewriteCond %{HTTP_USER_AGENT} .*W3C_Validator.* [NC]
RewriteCond %{HTTP:Accept-Encoding} gzip [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/aa/$1/index.xhtml.gz -f
RewriteRule ^(.*)$ /wp-content/cache/aa/$1/index.xhtml.gz [L,S=5]
&nbsp;
RewriteCond %{HTTP:Accept} application/xhtml\+xml [NC]
RewriteCond %{HTTP:Accept-Encoding} gzip [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/aa/$1/index.xhtml.gz -f
RewriteRule ^(.*)$ /wp-content/cache/aa/$1/index.xhtml.gz [L,S=4]
&nbsp;
RewriteCond %{HTTP:Accept-Encoding} gzip [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/aa/$1/index.html.gz -f
RewriteRule ^(.*)$ /wp-content/cache/aa/$1/index.html.gz [L,S=3]
&nbsp;
RewriteCond %{HTTP_USER_AGENT} .*W3C_Validator.* [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/aa/$1/index.xhtml -f
RewriteRule ^(.*)$ /wp-content/cache/aa/$1/index.xhtml [L,S=2]
&nbsp;
RewriteCond %{HTTP:Accept} application/xhtml\+xml [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/aa/$1/index.xhtml -f
RewriteRule ^(.*)$ /wp-content/cache/aa/$1/index.xhtml [L,S=1]
&nbsp;
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/aa/$1/index.html -f
RewriteRule ^(.*)$ /wp-content/cache/aa/$1/index.html [L]
&nbsp;
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)\.rdf\ HTTP/ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/rdf/%1.html/index.rdf -f
RewriteRule ^(.*)$ /wp-content/rdf/%1.html/index.rdf [L,S=1]
&nbsp;
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(error|w3c|openid)(/?.*)\ HTTP/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /X/%1%2 [L]
&nbsp;
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(y_key_bf61afd498f7623a\.html|google3bb7b7e1032ad0d4\.html|yadis\.xrdf|askapache-home\.rdf|os-description\.xml|labels\.rdf|gnu-fdl\.txt|wlmmanifest\.xml|robots\.txt)\ HTTP/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /X/%1 [L]
&nbsp;
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /X(.*)\ HTTP/ [NC]
RewriteRule .* - [F]
&nbsp;
RewriteRule ^osq?(.*)$ /wp-content/plugins/wp-opensearch.php?$1 [QSA,L]
&nbsp;
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /wp-login(.+)\ HTTP/ [NC]
#RewriteRule .+ https://www.askapache.com/wp-login%1 [R,L]
&nbsp;
RewriteCond %{REQUEST_URI} ^/cgi-bin/(hash|java)\.cgi$ [NC]
RewriteCond %{HTTP:P3P} ^(([^:]+):(.+))$ [NC]
RewriteRule .* - [E=HTTP_JS:%{HTTP:P3P},E=HTTP_US:%2,E=HTTP_PA:%3]
&nbsp;

RewriteCond %{HTTP_ACCEPT} application/xrds\+xml
RewriteCond %{HTTP_ACCEPT} !application/xrds\+xml\s*;\s*q\s*=\s*0(\.0{1,3})?\s*(,|$)
RewriteRule ^$ http://www.askapache.com/yadis.xrdf [R,L]
&nbsp;
RewriteCond %{HTTP_USER_AGENT} !^(FeedBurner|FeedValidator|talkr.com).* [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(feed|rdf|rss|rss2|atom)/?.*\ HTTP/ [NC]
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(feed|rdf|rss|rss2|atom|wp-atom|wp-feed|wp-rdf|wp-rss|wp-rss2).*\ HTTP/ [NC]
RewriteRule .* http://feeds.askapache.com/apache/htaccess? [R=302,L]
&nbsp;
#RewriteCond %{REMOTE_ADDR} ^$
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.+)\.phps$ /cgi-bin/phps.php?file=$1.php [L,NC]</pre>
<p><a href="http://www.askapache.com/htaccess/real-world-htaccess-files.html"></a><a href="http://www.askapache.com/htaccess/real-world-htaccess-files.html">Real-Life Htaccess Files from My Server</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/real-world-htaccess-files.html/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>30x Faster WP-Super Cache Site Speed</title>
		<link>http://www.askapache.com/web-hosting/super-speed-secrets.html</link>
		<comments>http://www.askapache.com/web-hosting/super-speed-secrets.html#comments</comments>
		<pubDate>Thu, 18 Mar 2010 15:43:21 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[devshm]]></category>
		<category><![CDATA[File System]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[memory bandwidth]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Private Server]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[SLRAM]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[speed improvements]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[SymLinks]]></category>
		<category><![CDATA[tmpfs]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[webhosts]]></category>
		<category><![CDATA[WP-Super Cache]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3220</guid>
		<description><![CDATA[<p><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html" id="id0"></a></p>
<p>NOT a typo..  30x is measurable, well-documented, and easily tested.  This is what <strong>open-source</strong> is about.   I haven’t had time to post much the past year, I'm always working!  So I wanted to make up for that by publishing an article on a topic that would blow your mind and be something that you could actually start using and really get some benefit out of it. This is one of those articles that the majority of web hosting companies would love to see in paperback, <strong>so they could burn it.</strong></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html"><img src="http://uploads.askapache.com/2009/09/top.jpg" alt="Top showing swap and memory" title="Top showing swap and memory" width="434" height="52" class="size-full wp-image-3270" /></a></p>
<p>I haven&#8217;t had time to post much the past year, so I wanted to make up for that by publishing an article on a topic that would blow your mind and be something that you could actually start using and really get some benefit out of it.  This is one of those articles that the majority of web hosting companies would love to see in paperback, <strong>so they could burn it</strong>.  Now ask yourself, if a webhost makes money based on how much memory, bandwidth, and data used by a customer, what would they not want their customers to do?  That&#8217;s right, they do not want their customers to learn how to minimize and drastically reduce these moneymakers.  They get giddy when you complain about slow-site-speed, or that it takes a long time for your site to load, because they have exactly the right answer- upgrade your memory, bandwidth, and data by purchasing a more expensive plan.</p>
<p class="anote"><strong>WARNING</strong>!!  This article has some seriously advanced stuff in it, pretty far beyond my skill level as well (getting there).  I personally shutdown some of my own servers with various webhosts because of this.. Note I said personally, not intentionally.  Even after spending almost a year (this has been in my drafts folder a long time) using TMPFS on as many machines as I can, I still make mistakes (gotta pay attention!) and lose a tmpfs folder..   Oh and if you go experimenting with this stuff on your web host, you will almost definately, most certainly be on the road to getting your account terminated if you are with one of the cheap hosts.  They hate this stuff because it cuts right into the heart of their profit curves and can seriously disrupt a poorly configured machine.  DO NOT TRY THIS!!  (except and of course on your own development machines).   Of course the whole point of this article is how you can take advantage of this incredible filesystem to get crazy speed improvements..  Those are the follow up articles ;)</p>
<p>For those of you who thought modifying your server httpd.conf and htaccess files is very dangerous, you are right.  But this is not like that, this is dangerous in the sense that if you try to rush through with your super amazing &#8220;copy and paste skills&#8221; (script kids) you will easily lose entire folders.  That&#8217;s because TMPFS is stored in RAM/Memory, and upon reboot RAM is cleared.  I personally loathe disclaimers, and if you look around you will see there aren&#8217;t many even with all my sloppy poorly documented articles&#8230;  So be careful if you feel up to going further.</p>
<h2>Introducing tmpfs</h2>
<p>If I had to <strong>explain tmpfs</strong> in one breath, I&#8217;d say that tmpfs is like a ramdisk, but different. Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it&#8217;s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I&#8217;ve had the opportunity to meet.</p>
<h2>Beware of WebHosts</h2>
<p>What is a modern day web hosting company?  What costs do they actually have?  A webhost&#8217;s only unique ability is their connection to the Internet.  That is why you can see such tremendous link speed.  Other than that they consist of servers that are getting smaller and cheaper for them every month.  The servers they use are generally just like any computer, except much larger and built specifically for multi-tasking.</p>
<blockquote cite="http://content.dell.com/us/en/enterprise/virtualization-what-is-it.aspx">
<p>Virtualization allows you to run multiple applications and operating systems independently on a single server. Additionally, administrators can quickly move workloads from one virtual workspace to another — easily prioritizing business needs while maximizing server resources&#8230;.</p>
<p>Virtualization removes the limitations of the traditional IT approach, enabling <strong>a single PowerEdge server</strong> to operate <strong>multiple applications simultaneously in &#8220;virtual machines&#8221;</strong></p>
</blockquote>
<h2>Hosting Company Tricks</h2>
<p>Web hosts like to vaguely describe their products as if you are buying your own powerful machine, but in reality you get placed on the same machine as hundreds or thousands of other customers, and the server basically creates an operating system for each customer using virtualization technology.  Everyone on the machine literally is sharing the same RAM and resources, many times even sharing IP address&#8217;s, and the virtualization software lets them limit the amount of memory / cpu / disk / and bandwidth for each of these virtual machines.  That is why so often when a web host has an outage they make big public announcements and it appears that hundreds or thousands of their customers have been affected.. One of their server farm machines goes offline and it literally takes down all the customers virtualized machines with it.</p>
<h3>Why it gets Evil</h3>
<p>Don&#8217;t get me wrong, I absolutely love this technology, both the hardware virtualization and the software side, but what I truly do not appreciate is how these companies take advantage of their customers every day and know it.  Here&#8217;s what they do, they make justifications about why one plan costs more than another, and these justifications are always about the same thing:  CPU&#8217;s, how fast the data can crunch..  RAM/Memory: How fast and how much your server can handle in terms of traffic&#8230; Disk Usage:  How much storage you have&#8230; And finally bandwidth: How fast can people get data off your sites, and how many people can connect.</p>
<p>Now lets think for a second.  The webhost has a BIG computer/server/machine that has MASSIVE amounts of RAM, DISK, PROCESSING power, and NETWORK bandwidth.. but just like anything they all have limits.   So if this machine has 10GB of RAM, and the webhost offered plans that have 1GB of RAM, then on that machine they can only have 10 customers right?  WRONG.  If each customer pays $100/month, then of course they would love to have as many customers on that machine as possible.  This builtin incentive is just the reality and isn&#8217;t anyone fault.</p>
<h3>Where it gets Evil</h3>
<p>Here&#8217;s what goes on.. all the host advertises is the 1GB of guaranteed RAM with your machine, but for even if the web server was fairly busy it would never use all of that ram because all the software is careful not to use too much, or has no need for any RAM.  Runtime libraries and internal caches use ram, but it&#8217;s not directly accessed by the customer, only the software.   What happens is when those 10 customers aren&#8217;t using 100% of their ram, which never happens, then the virtualization technology can use that RAM elsewhere.  So technically you do have 1GB of RAM available, but if you aren&#8217;t using it then it is essentially FREE RAM that they can sell to another customer.  The only way this wouldn&#8217;t work of course is if all 11 customers somehow used 100% of RAM simultaneously, at that point the 11th customer would be ramless.  But that is impossible because the system is a load-balancing system that provides both an upper and a lower limit to how much RAM is allotted to each virtual machine.</p>
<p>It sounds unrealistic but I see server farms all the time that are stuffed full of virtual machines, like situations where there are 100 1GB customers all sharing 10GB of RAM..  no-one uses the whole 1GB allotted to them as the maximum amount they can use, and they don&#8217;t know because it appears they have a lot of free RAM, but really that is virtual RAM and could be used by anyone else on the machine.</p>
<h3>Where it gets Fun (for me)</h3>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"class="IFL" ><img src="http://uploads.askapache.com/2010/03/askapache-htop.jpg" alt="The HTOP command in full color to manage mysql" title="The HTOP command in full color to manage mysql" width="404" height="176" class="size-full wp-image-4149" /></a>This is actually even worse for anyone who is using what they call &#8220;shared-hosting&#8221; which is the budget hosting that is the most common.  With shared-hosting there is actually some skill involved on the hosting companies part, like real linux skills.  In this setup they may or more often may not use any virtualization software.  It&#8217;s just a vanilla multi-user server machine where each customer gets a restricted unix account that powers their website using the same system as thousands of others on the box.  This is usually dirt cheap because it costs so little to do, but alot of companies charge outrageous amounts for shared-hosting because they make it look really full-featured, which it can be, they just don&#8217;t mention 1000 other people use the same machine, hard-drive, /tmp directory, network device, IP address, etc..  Alot of the times the cheaper end of the spectrum is where the most gifted system administrators are located, they are so good with linux administration that they could fit 10 customers and 100 websites on an XBOX converted to run linux, and you&#8217;d think you got a great deal until you found out! lol.  Anyone alive is able to buy more hardware to expand their capacity to take on more customers,  but it takes a lot of knowhow and real skill to have that many users on 1 machine.  I&#8217;ve seen pretty extreme cases that are analogous to the XBOX example (which is possible by the way).<br class="C" /></p>
<p>I personally love shared-hosting environments, because for those of us who know almost as much or more than the system administrators running the machine we are able to use a disproportionate (legally) amount of the CPU and RAM available on the system.  So for example my sites would  all show up fast and be able to handle more traffic than several other customers combined.  Not because<br />
anything has been circumvented, but because I am able to access and utilize as much of the guaranteed 1GB of RAM that I am paying for every month, which is usually just a few bucks.  The downside is that when you have corporate sites or really high-traffic sites then you are forced to move to a more powerful machine..  </p>
<p>This leads to a familiar situation for some of you..  When your site starts becoming popular and you are getting a lot of traffic, this means that your site could be using 10x the amount of RAM and Bandwidth of any other customer in that server farm.  And what that really means to the webhost is that you are costing them 10x what anyone else is..  And if they removed you, they would have the space for 10 new customers to take your place, and they would make 10x more money.  DreamHost is notorious for terminating accounts because of that..  It happened to me except I was given the option to pay 5x more a month for their &#8220;upgrade&#8221; to a VPS.  Giant shared-hosts advertise like crazy how they offer unlimited bandwidth, but <strong>when you start using 100x more bandwidth than anyone on your server you are costing them 100x what you are paying them, every month</strong>.  That&#8217;s why you will never see a webhost offering this kind of unlimited bandwidth that doesn&#8217;t require you to sign a contract giving them permission to terminate your account <em>for any reason</em>.  Seriously read the fine print at DreamHost or anywhere else, it&#8217;s included because that is a core part of their business to terminate anyone using too much bandwidth since that is bandwidth they can&#8217;t sell to dozens of other customers.  That&#8217;s why I eventually closed my account with them and moved to a legitimate company, it&#8217;s a great host for spammers though.</p>
<p>Back in the mid-90&#8242;s I was doing a lot of war-dialing with my modem and discovering all sorts of networks and machines, many of them were Unix and Solaris based public systems, and when I managed to gain access to the system and found myself staring at a unix shell I was very excited but also a total idiot.  In those days of using the phone networks to research unknown systems it was very difficult for anyone to actually get the phone company to trace a call, so instead of what happens today where it is child&#8217;s play to trace an IP address, back then it was a very real back-and-forth battle between the system admin and whoever was gaining access to their system.  Essentially, I would gain a shell or some kind of terminal, and just go at it trying to figure out what it could do, trying all kinds of commands.  Inevitably this would eventually alert even the laziest admin and they would proceed to attempt to lock me out. It was great sport and extremely addictive.  When my favorite system (a massive sun machine in the basement of a big library) finally locked me out and I couldn&#8217;t get back in I went to my local library and got some reading material &#8212; one of my favorites was the red hat bible.  I was able to acquire my own computer and the first thing I did was install red hat linux onto it from the discs included with the book.  For the next several years I was essentially offline, all we had at home was a modem and it was becoming difficult to locate any more systems in my area code.. I was into phreaking of course as well, but I never was able to make free long-distance war-dialing a reality.  So I just read the books and learned what I could.  I would also goto the library when I could in order to use their machines which were connected to the internet (before aol it was much different than today&#8217;s internet) and since my time was short I would download as many documents as I could so that I could read them offline.  The TLDP documentation that we know today was around back then in various forms, and I read every HOWTO in the index, though not understanding half.  The other big resource I found for really intense reading was the <a href="http://www.kernel.org/doc/Documentation/" rel="nofollow" >kernel documentation</a>, which admitedly I still don&#8217;t comprehend 1/4th of..   I try and peruse all the new documents when a new kernel is released, since the kernel is where all the real action is, hence the military authoritative name, and that is how I discovered one of the coolest features of Linux that I have found.  TMPFS!</p>
<h2>TMPFS kills the RAMDISK</h2>
<p>Ok so we all know what RAM is, it&#8217;s the memory cards that most people never see that is used by the computer to store and access data that all programs need.  RAM is very expensive compared to most PC components, because it&#8217;s what makes a computer blazing fast or slow.  So real quick lets look at a few (there are not many) ways that various linux hackers use RAM in non-conventional ways in the past.</p>
<p>Tmpfs is a file system which keeps all files in virtual memory.  Everything is temporary in the sense that no files will be created on your hard drive. If you reboot, everything in tmpfs will be lost.</p>
<p>In contrast to RAM disks, which get allocated a fixed amount of physical RAM, tmpfs grows and shrinks to accommodate the files it contains and is able to swap unneeded pages out to swap space.</p>
<p>Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it&#8217;s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I&#8217;ve had the opportunity to meet.</p>
<p>If I had to <strong>explain tmpfs</strong> in one breath, I&#8217;d say that tmpfs is like a ramdisk, but different. Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it&#8217;s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I&#8217;ve had the opportunity to meet.</p>
<p><br class="C" /></p>
<p>What kind of filesystem is used on your server to store all your site files?  EXT4, REISERFS, EXT3, NFS, etc.. are the usual filesystems, Windows users are limited to the NTFS filesystem.   A filesystem is different than a device, a device is a hard-drive disk.  A filesystem is how the device is formatted to allow for file and folder structures.  A hard drive is slow compared to RAM, no question about that.  So what if instead of your server serving files off a hard-drive it served files stored in RAM?  <strong>30x faster thats what happens!</strong></p>
<p class="wnote">I just figured out how to store my cached static files created by WP-Super Cache in my server&#8217;s RAM, and the difference is unbelievable.  My &#8220;AskApache Crazy Cache&#8221; plugin basically forces WP-Super Cache, Hyper Cache, etc.. to recreate a static cached file for every page on a blog.  For the AskApache.com site this takes around 3 minutes to complete.  Once I switched to using this new method of storing the files on RAM I am able to re-cache the entire site in about 15 seconds!!!!</p>
<p class="wnote">tmpfs is a dynamically expandable/shrinkable ramdisk, and will<br />
# use almost no memory if not populated with files</p>
<blockquote cite="">
<p>Tmpfs is a file system which keeps all files in virtual memory.</p>
<p>Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost.</p>
<p>tmpfs puts everything into the kernel internal caches and grows and shrinks to accommodate the files it contains and is able to swap unneeded pages out to swap space. It has maximum size limits which can be adjusted on the fly via &#8216;mount -o remount &#8230;&#8217;</p>
<p>If you compare it to ramfs (which was the template to create tmpfs) you gain swapping and limit checking. Another similar thing is the RAM disk (/dev/ram*), which simulates a fixed size hard disk in physical RAM, where you have to create an ordinary filesystem on top. Ramdisks cannot swap and you do not have the possibility to resize them.</p>
<p>Since tmpfs lives completely in the page cache and on swap, all tmpfs pages currently in memory will show up as cached. It will not show up as shared or something like that. Further on you can check the actual RAM+swap use of a tmpfs instance with df(1) and du(1).</p>
</blockquote>
<p>Both tmpfs and ramfs mount will give you the power of fast reading and writing files from and to the primary memory. When you test this on a small file, you may not see a huge difference. You’ll notice the difference only when you write large amount of data to a file with some other processing overhead such as network.</p>
<h2>TMPFS uses RAM+SWAP</h2>
<p>TMPFS is another filesystem with uniquely cool capabilities.  It stores any files contained within it on RAM and in SWAP which means your server can access any files stored on TMPFS without even having to access the disk, which according to technical stats is around 30 times faster than accessing a file off disk.</p>
<p>Some other cool aspects of TMPFS are that it intelligently and automatically sizes itself to be just alittle bigger then it needs to be.  So when you remove files to a folder stored on a TMPFS filesystem, the TMPFS filesystem shrinks by allocating less RAM and/or SWAP.  Conversely when adding files to TMPFS it grows larger.  You can set the max-size and max-number-of-files as a mount option to make sure your TMPFS never uses all of the available RAM and SWAP, which would halt your server.</p>
<h3>Swap</h3>
<p>Find the swap size.</p>
<pre># free -m -t
             total       used       free     shared    buffers     cached
Mem:           458         93        364          0          0          0
-/+ buffers/cache:         93        364
Swap:          900          0        900
Total:        1358         93       1264</pre>
<pre>Adding 3004144k swap on /dev/sdb2.  Priority:-1 extents:1 across:3004144k
Adding 2096472k swap on /dev/sda3.  Priority:-2 extents:1 across:2096472k</pre>
<h2>Using TMPFS for Cache</h2>
<p>The method here will show how to create and use a TMPFS filesystem to hold all the static files created by WP-Super Cache.  These static files are served to visitors instead of loading php for every request, so by moving those static files to TMPFS your server will be able to access and start sending your site to the browser 30x faster!</p>
<p>The WP-Super Cache plugin stores all the static files in the wp-content/cache folder of your WordPress installation, so to enable TMPFS we simply will create a new TMPFS filesystem and mount it to the wp-content/cache folder.  That makes anything in that folder (all the static files) be part of the TMPFS filesystem.</p>
<h2>Boosting Cache with TMPFS</h2>
<p>There are a lot of maybe new concepts surrounding TMPFS and it may seem too complicated, but the process of actually setting up a robust tmpfs to use for wp-super-cache&#8217;s cache folder is actually very simple.  As long as you have shell access to your server and the permissions required (any sudo or private server should be good to go) you can set this up in a couple minutes and not really have to give it a second thought or debug anything.  Here&#8217;s the process I&#8217;ve used on several client sites.</p>
<ol>
<li>Create a TMPFS Filesystem and Mount at /wp-content/cache/</li>
<li>Restore TMPFS Cached Files across Reboots</li>
<li>Keep a semi-current mirror of the TMPFS files on Disk</li>
</ol>
<p><br class="C" /></p>
<h3>Create TMPFS at wp-content/cache</h3>
<p>/etc/fstab</p>
<pre>tmpfs /home/askapache/wp-content/cache tmpfs defaults,size=2g,noexec,nosuid,uid=648,gid=648,mode=1755 0 0</pre>
<h3>Restoring TMPFS across Reboots</h3>
<p>In /etc/rc.local</p>
<pre>ionice -c3 -n7 nice -n 19 rsync -ahv &#45;-stats &#45;-delete /_b/tmpfs/cache/ /home/askapache/wp-content/cache/ 1&gt;/dev/null</pre>
<h3>Mirroring TMPFS to Disk</h3>
<p>Cronjob entry</p>
<pre>*/5 * * * * /usr/bin/ionice -c3 -n7 /bin/nice -n 19 /usr/bin/rsync -ah &#45;-stats &#45;-delete /home/askapache/wp-content/cache/ /_b/tmpfs/cache/ 1&gt;/dev/null</pre>
<p><span id="more-3220"></span></p>
<h2>/tmp, /var/run, and /var/lock</h2>
<p>The directories /tmp, /var/run, and /var/lock contain files that are not needed across reboots.  This means they are ideal candidates for tmpfs.  HEre&#8217;s how to do it.</p>
<pre>tmpfs /var/run tmpfs defaults,rw,nosuid,mode=0755 0 0</pre>
<pre>tmpfs /var/lock tmpfs defaults,rw,noexec,nosuid,nodev,mode=1777 0 0</pre>
<h2>Resize /dev/shm</h2>
<p>You can view your current /dev/shm size with the command <code>df -ha|grep /dev/shm</code> then if you want to resize that use the command:</p>
<pre>mount -t tmpfs -o remount,size-2G,rw,nosuid,nodev tmpfs /dev/shm</pre>
<pre>Secure /dev/shm:
&nbsp;
Step 1: Edit your /etc/fstab:
&nbsp;
nano -w /etc/fstab
&nbsp;
Locate:
&nbsp;
none /dev/shm tmpfs defaults,rw 0 0
&nbsp;
Change it to:
&nbsp;
none /dev/shm tmpfs defaults,nosuid,noexec,rw 0 0
&nbsp;
Step 2: Remount /dev/shm:
&nbsp;
mount -o remount /dev/shm
&nbsp;
guilt makes extensive use of the &#039;$$&#039; shell variable for temporary
files in /tmp. This is a serious security vulnerability; on multi-user
systems it allows an attacker to clobber files with something like the
following:
&nbsp;
for i in `seq 1 32768`; do
ln -sf /etc/passwd /tmp/guilt.log.$i;
done
&nbsp;
(In this example, if root does e.g. &#039;guilt push&#039;, /etc/passwd will get
clobbered.)</pre>
<p><br class="C" /></p>
<h3>Securing and Using /tmp</h3>
<ul>
<li><a href="http://www.sysadmin.md/secure-temporary-folders-on-existing-unix-or-linux-systems.html" rel="nofollow" >Secure temporary folders on existing Unix or Linux systems</a></li>
<li><a href="https://wiki.torproject.org/noreply/TheOnionRouter/OperationalSecurity" rel="nofollow" >Encrypt Storage and Swap Space</a></li>
</ul>
<p><a id="tmpfs-mount"></a></p>
<h2>tmpfs mount parameters</h2>
<p>A good way to find a good tmpfs upper-bound is to use top to monitor your system&#8217;s swap usage during peak usage periods. Then, make sure that you specify a tmpfs upper-bound that&#8217;s slightly less than the sum of all free swap and free RAM during these peak usage times. </p>
<p><strong>mode=1777</strong> sets sticky bit on directory. Only file owners can delete files in this directory.</p>
<p>The following parameters accept a suffix k, m or g for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.</p>
<ul>
<li><strong>size</strong>:  Override default maximum size of the filesystem.  The size is given in bytes, and rounded down to entire pages.  The default is half of the memory.The limit of allocated bytes for this tmpfs instance. The default is half of your physical RAM without swap. If you oversize your tmpfs instances the machine will deadlock since the OOM handler will not be able to free that memory.</li>
<li><strong>nr_inodes</strong>:  Set number of inodes.</li>
<li><strong>nr_blocks</strong>:  Set number of blocks.</li>
<li><strong>mode</strong>: The permissions as an octal number</li>
<li><strong>uid</strong>: The user id</li>
<li><strong>gid</strong>: The group id</li>
</ul>
<pre>mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs</pre>
<p>Will give you tmpfs instance on /mytmpfs which can allocate 10GB RAM/SWAP in 10240 inodes and it is only accessible by root.</p>
<p><a id="tmp-tmpfs"></a></p>
<h2>Using tmpfs for /tmp storage</h2>
<p>Many users find it very convenient to use tmpfs for /tmp and /var/tmp which does a number of positive things.  Any temporary files are instead created in RAM not your hard-drive, which means that reading/writing/accessing those temporary files by various processes doesn&#8217;t slow down your hard-drive read/writes/accesses for your other processes.  This also has a side-effect of making your hard-drive have a longer life as it reduces activity by a huge amount.</p>
<p>Remember that tmpfs uses both RAM and swap, so make sure your machine has a large swapfile, like gigabytes.  If your tmpfs consumes all the swap and RAM then you are screwed, so make sure that you correctly set the mount options for the tmpfs so that it doesn&#8217;t do that.  If your /tmp or /var/tmp gets filled with tmp files that for some reason don&#8217;t get deleted except at reboot, and your machine has a very high uptime, then you will want to run some cron jobs to periodically clean the /tmp and /var/tmp directories of older files&#8230;</p>
<p>Here&#8217;s an example scenario: let&#8217;s say that we have an existing filesystem mounted at /tmp. However, we decide that we&#8217;d like to start using tmpfs for /tmp storage.</p>
<p>with recent 2.4 kernels, you can mount your new /tmp filesystem without getting the &#8220;device is busy&#8221; error: </p>
<pre>mount tmpfs /tmp -t tmpfs -o size=64m</pre>
<p>With a single command, your new tmpfs /tmp filesystem is mounted at /tmp, on top of the already-mounted partition, which can no longer be directly accessed. However, while you can&#8217;t get to the original /tmp, any processes that still have open files on this original filesystem can continue to access them. And, if you umount your tmpfs-based /tmp, your original mounted /tmp filesystem will reappear. In fact, you can mount any number of filesystems to the same mountpoint, and the mountpoint will act like a stack; unmount the current filesystem, and the last-most-recently mounted filesystem will reappear from underneath.</p>
<p><a id="bind-mounts"></a></p>
<h2>Bind Mounts</h2>
<p>Using bind mounts, we can mount all, or even part of an already-mounted filesystem to another location, and have the filesystem accessible from both mountpoints at the same time!</p>
<p>For example, you can use bind mounts to mount your existing /tmp filesystem to /sites/askapache.com/tmp, as follows:</p>
<pre>mount &#45;-bind /tmp /sites/askapache.com/tmp</pre>
<p>Now, if you look inside /sites/askapache.com/tmp, you&#8217;ll see your /tmp filesystem and all its files. And if you modify a file on your /tmp filesystem, you&#8217;ll see the modifications in /sites/askapache.com/tmp as well. This is because <strong>they are one and the same filesystem; the kernel is simply mapping the filesystem to two different mountpoints for us</strong>. </p>
<p>Note that when you mount a filesystem somewhere else, any filesystems that were mounted to mountpoints inside the bind-mounted filesystem will not be moved along. In other words, if you have /tmp/cache on a separate filesystem, the bind mount we performed above will leave /sites/askapache.com/tmp/cache empty. You&#8217;ll need an additional bind mount command to allow you to browse the contents of /tmp/cache at /sites/askapache.com/tmp/cache:</p>
<pre>mount &#45;-bind /tmp/cache /sites/askapache.com/tmp/cache</pre>
<h3>Bind mounting and /dev/shm</h3>
<p>glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for POSIX shared memory (shm_open, shm_unlink). Adding the following line to /etc/fstab should take care of this:</p>
<pre>tmpfs  /dev/shm  tmpfs  defaults  0 0</pre>
<p>Many systems by default have a tmpfs filesystem mounted at /dev/shm that defaults to a size of half of your physical RAM without swap.  Say you decide that you&#8217;d like to start using tmpfs for /tmp, which currently lives on your root filesystem. Rather than mounting a new tmpfs filesystem to /tmp (which is possible), you may decide that you&#8217;d like the new /tmp to share the currently mounted /dev/shm filesystem. However, while you could bind mount /dev/shm to /tmp and be done with it, your /dev/shm contains some directories that you don&#8217;t want to appear in /tmp. So, what do you do? How about this:</p>
<pre>mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount &#45;-bind /dev/shm/tmp /tmp</pre>
<p>In this example, we first create a /dev/shm/tmp directory and then give it 1777 perms, the proper permissions for /tmp. Now that our directory is ready, we can mount /dev/shm/tmp, and only /dev/shm/tmp to /tmp. So, while /tmp/foo would map to /dev/shm/tmp/foo, there&#8217;s no way for you to access the /dev/shm/bar file from /tmp.</p>
<p><br class="C" /></p>
<p><a id="default-tmpfs-workaround"></a></p>
<h2>/etc/default/tmpfs WorkAround</h2>
<pre>$ cat /etc/default/tmpfs
# SHM_SIZE sets the maximum size (in bytes) that the /dev/shm tmpfs can use.
# If this is not set then the size defaults to the value of TMPFS_SIZE
# if that is set; otherwise to the kernel&#039;s default.
#
# The size will be rounded down to a multiple of the page size, 4096 bytes.
SHM_SIZE=524288000
# TMPFS_SIZE sets the max size that /dev/shm can use.  By default, the
# kernel sets this upper limit to half of available memory.
TMPFS_SIZE=524288000</pre>
<p><a id="rsync-vs-cp"></a></p>
<h2>RSYNC vs. CP</h2>
<pre>rsync [options]  SRC DEST
rsync -av &#45;-delete &#45;-stats /home/wincom/public_html/wp-content/cache/ /backups/tmp-mnt/cache/
-a, &#45;-archive               archive mode; same as -rlptgoD (no -H)
-r, &#45;-recursive             recurse into directories
-l, &#45;-links                 copy symlinks as symlinks
-p, &#45;-perms                 preserve permissions
-t, &#45;-times                 preserve times
-g, &#45;-group                 preserve group
-o, &#45;-owner                 preserve owner (super-user only)
-D                          same as &#45;-devices &#45;-specials
    &#45;-devices               preserve device files (super-user only)
    &#45;-specials              preserve special files
 -h, &#45;-human-readable        output numbers in a human-readable format
     &#45;-progress              show progress during transfer</pre>
<p><a id="mount-options"></a></p>
<h2>Mount Options</h2>
<p>The following options apply to any file system that is being mounted (but not every file  system  actually honors them)</p>
<ul>
<li><code>async</code> All I/O to the file system should be done asynchronously.</li>
<li><code>atime</code> Update inode access time for each access. This is the default.</li>
<li><code>auto</code> Can be mounted with the -a option.</li>
<li><code>defaults</code> Use default options: rw, suid, dev, exec, auto, nouser, and async.</li>
<li><code>dev</code> Interpret character or block special devices on the file system.</li>
<li><code>exec</code> Permit execution of binaries.</li>
<li><code>group</code> Allow an ordinary (i.e., non-root) user to mount the file system if one of his groups matches the group of the device.  This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line group,dev,suid).</li>
<li><code>mand</code> Allow mandatory locks on this filesystem. See fcntl(2).</li>
<li><code>_netdev</code> The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).</li>
<li><code>noatime</code> Do not update inode access times on this file system (e.g, for faster access on the news spool to speed up news servers).</li>
<li><code>nodiratime</code> Do not update directory inode access times on this filesystem.</li>
<li><code>noauto</code> Can only be mounted explicitly (i.e., the -a option will not cause the file system to be mounted).</li>
<li><code>nodev</code> Do not interpret character or block special devices on the file system.</li>
<li><code>noexec</code> Do not allow direct execution of any binaries on the mounted file system.  (Until recently it was possible to run binaries anyway using a command like /lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.)</li>
<li><code>nomand</code> Do not allow mandatory locks on this filesystem.</li>
<li><code>nosuid</code> Do not allow set-user-identifier or set-group-identifier bits to take effect. (This seems safe, but is in fact rather unsafe if you have suidperl(1) installed.)</li>
<li><code>nouser</code> Forbid an ordinary (i.e., non-root) user to mount the file system.  This is the default.</li>
<li><code>owner</code> Allow an ordinary (i.e., non-root) user to mount the file system if he is the owner of the device.  This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line owner,dev,suid).</li>
<li><code>remount</code> Attempt to remount an already-mounted file system.  This is commonly used to change the mount flags for a file system, especially to make a readonly file system writeable. It does not change device or mount point.</li>
<li><code>ro</code> Mount the file system read-only.</li>
<li><code>_rnetdev</code> Like _netdev, except &#8220;fsck -a&#8221; checks this filesystem during rc.sysinit.</li>
<li><code>rw</code> Mount the file system read-write.</li>
<li><code>suid</code> Allow set-user-identifier or set-group-identifier bits to take effect.</li>
<li><code>sync</code> All I/O to the file system should be done synchronously. In case of media with limited number of write cycles (e.g. some flash drives) &#8220;sync&#8221; may cause life-cycle shortening.</li>
<li><code>dirsync</code> All directory updates within the file system should be done synchronously.  This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename.</li>
<li><code>user</code> Allow  an ordinary user to mount the file system.  The name of the mounting user is written to mtab so that he can unmount the file system again.  This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid).</li>
<li><code>users</code> Allow every user to mount and unmount the file system.  This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line users,exec,dev,suid).</li>
</ul>
<p><a id="filesystems"></a></p>
<h2>Filesystems</h2>
<p>You can find out what is filesystems are in place by using one of the following linux commands:</p>
<pre>cat /etc/fstab
cat /etc/mtab
cat /proc/mounts
df -a</pre>
<h2>/etc/fstab</h2>
<pre>       /etc/fstab        file system table
       /etc/mtab         table of mounted file systems
       /etc/mtab~        lock file
       /etc/mtab.tmp     temporary file
       /etc/filesystems  a list of filesystem types to try</pre>
<p>From /etc/mtab</p>
<pre>none /tmp tmpfs size=128m,mode=1777 0 0</pre>
<p>From /proc/mounts</p>
<pre>none /tmp tmpfs rw,nodev,relatime,size=131072k 0 0</pre>
<p><br class="C" /></p>
<p><a id="fstab"></a></p>
<h2>/etc/fstab</h2>
<p>It is possible that files /etc/mtab and /proc/mounts don’t match. The first file is based only on the mount command options, but the content of the second file also depends on the kernel and others settings (e.g.  remote NFS server. In particular case  the  mount  command  may reports unreliable information about a NFS mount point and the /proc/mounts file usually contains more reliable information.)</p>
<p>This file is used in three ways:</p>
<ol>
<li>The following command (usually given in a bootscript) causes all file systems mentioned in fstab (of the proper type and/or having or not having the proper options) to be mounted as indicated, except for those whose line contains the noauto keyword. Adding the -F option will  make  mount  fork,  so that the filesystems are mounted simultaneously.
<pre>mount -a [-t type] [-O optlist]</pre>
</li>
<li>When mounting a file system mentioned in fstab, it suffices to give only the device, or only the mount point.</li>
<li>Normally, only the superuser can mount file systems.  However, when fstab contains the user option on a line, anybody can mount the corresponding system.</li>
</ol>
<p>The programs mount and umount maintain a list of currently mounted file systems in the file /etc/mtab.</p>
<p>Only the user that mounted a filesystem can unmount it again.  If any user should be able to unmount, then use users instead of user in the fstab line.  The owner option is similar to the user option, with the restriction that the user must be the owner of the special file.  The group option is similar, with the restriction that the user must be member of the group of the special file.</p>
<p>The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through fstab doing their thing.</p>
<h3>The first field, (fs_spec)</h3>
<p>Describes the block special device or remote filesystem to be mounted.  For ordinary mounts it will hold (a link to) a block special device node (as created by mknod(8)) for the device to be mounted, like ‘/dev/cdrom’ or ‘/dev/sdb7’.  For NFS mounts one will have <code><host>:<dir></code>, e.g., ‘knuth.aeb.nl:/’.  For procfs, use ‘proc’.</p>
<p>Instead of giving the device explicitly, one may indicate the (ext2 or xfs) filesystem that is to be mounted by its UUID or volume label (cf.  e2label(8) or xfs_admin(8)), writing LABEL=<label> or UUID=<uuid>, e.g., ‘LABEL=Boot’ or  ‘UUID=3e6be9de-8139-11d1-9106-a43f08d823a6’.  This will make the system more robust: adding or removing a SCSI disk changes the disk device name but not the filesystem volume label.</p>
<h3>The second field, (fs_file)</h3>
<p>Describes the mount point for the filesystem.  For swap partitions, this field should be specified as ‘none’. If the name of the mount point contains spaces these can be escaped as ‘\040’.</p>
<p>The  third  field,  (fs_vfstype),  describes the type of the filesystem.  Linux supports lots of filesystem types, such as adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, and possibly others. For more details, see mount(8).  <strong>For the filesystems currently supported by the running kernel, see /proc/filesystems</strong>.  An entry swap denotes  a  file  or  partition  to  be  used  for  swapping,  cf.  swapon(8).  An entry ignore causes the line to be ignored.  This is useful to show disk partitions which are currently unused.</p>
<h3>The fourth field, (fs_mntops)</h3>
<p>Describes the mount options associated with the filesystem.  It  is formatted as a comma separated list of options.  It contains at least the type of mount plus any additional options appropriate to the filesystem type.  For documentation on the available options for non-nfs file systems, see mount(8).  For documentation on all nfs-specific options have a look at nfs(5).</p>
<p>Common for all types of file system are the options:</p>
<ul>
<li><strong>noauto</strong>: (do not mount when &#8220;mount -a&#8221; is given, e.g., at boot time)</li>
<li><strong>user</strong>: (allow a user to mount)</li>
<li><strong>owner</strong>: (allow device owner to mount)</li>
<li><strong>pamconsole</strong>: (allow a user at the console to mount)</li>
<li><strong>comment</strong>: (e.g., for use by fstab-maintaining programs).</li>
</ul>
<h3>The fifth field, (fs_freq)</h3>
<p>Used for these filesystems by the dump(8) command to determine which filesystems need to be dumped.  If the fifth field is not present, a value of zero is returned and dump will assume that the filesystem does not need to be dumped.</p>
<h3>The  sixth  field,  (fs_passno)</h3>
<p>Used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time.  The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2.  Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware.  If the sixth field is not present or zero, a value of zero is returned and <strong>fsck will assume that the filesystem does not need to be checked</strong>.</p>
<h3>More Reading</h3>
<ul>
<li><a href="http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/" rel="nofollow" >Overview of RAMFS and TMPFS on Linux</a></li>
<li><a href='http://uploads.askapache.com/2009/09/ramfs-rootfs-initramfs.txt'>ramfs, rootfs and initramfs</a></li>
<li><a href='http://uploads.askapache.com/2009/09/tmpfs.txt'>Tmpfs is a file system which keeps all files in virtual memory</a></li>
<li><a href="http://www.ibm.com/developerworks/library/l-fs3.html" rel="nofollow" >IBM: Advanced filesystem implementor&#8217;s guide, Part 3</a></li>
<li><a href="http://en.wikipedia.org/wiki/TMPFS" rel="nofollow" >TMPFS Wikipedia Entry</a></li>
<li><a href="http://en.wikipedia.org/wiki/Shared_memory" rel="nofollow" >Shared Memory</a></li>
<li><a href="http://kevin.vanzonneveld.net/techblog/article/create_turbocharged_storage_using_tmpfs/" rel="nofollow" >Create turbocharged storage using tmpfs</a></li>
<li><a href="http://dev.mysql.com/doc/refman/4.1/en/temporary-files.html" rel="nofollow" >Where MySQL Stores Temporary Files</a></li>
<li><a href="http://www.linuxized.com/2009/05/speeding-up-firefox-with-tmpfs-and-automatic-rsync/" rel="nofollow" >speeding up firefox with tmpfs and automatic rsync</a> <a href="http://www.linuxized.com/wp-content/uploads/2009/05/speedfox" rel="nofollow" >(shell-script)</a> <a href="http://autoverse.net/blog/2009/apr/23/speed-firefox/" rel="nofollow" >Original</a></li>
<li><a href="http://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt" rel="nofollow" >kernel documentation for tmpfs</a></li>
<li><a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=386368" rel="nofollow" >initscripts: please don&#8217;t mount /dev/shm noexec</a></li>
<li><a href="http://forums.debian.net/viewtopic.php?t=16450" rel="nofollow" >HOWTO: Using tmpfs for /tmp, /var/{log,run,lock&#8230;}</a></li>
<li><a href="http://forums.gentoo.org/viewtopic-t-371889-highlight-tmpfs.html" rel="nofollow" >Gentoo Forums: Using tmpfs for /var/{log,lock,&#8230;}</a></li>
<li><a href="http://forums.gentoo.org/viewtopic-t-717117-highlight-tmpfs.html" rel="nofollow" >[TIP] Firefox and tmpfs: a surprising improvement</a></li>
</ul>
<blockquote cite="http://openquery.com/blog/experiment-mysql-tmpdir-on-tmpfs"><p>
<cite><a href="http://openquery.com/blog/experiment-mysql-tmpdir-on-tmpfs" rel="nofollow" >Experiment: MySQL tmpdir on tmpfs</a></cite></p>
<p>In MySQL, the tmpdir path is mainly used for disk-based sorts (if the sort_buffer_size is not enough) and disk-based temp tables. The latter cannot always be avoided even if you made tmp_table_size and max_heap_table_size quite large, since MEMORY tables don’t support TEXT/BLOB type columns, and also since you just really don’t want to run the risk of exceeding available memory by setting these things too large.</p>
</blockquote>
<p><br class="C" /></p>
<h2>Use tmpfs for MySQL</h2>
<pre>&#45;-tmpdir=path, -t path</pre>
<blockquote cite="http://dev.mysql.com/doc/refman/4.1/en/server-options.html#option_mysqld_tmpdir"><p>The path of the directory to use for creating temporary files. It might be useful if your default /tmp directory resides on a partition that is too small to hold temporary tables. Starting from MySQL 4.1.0, this option accepts several paths that are used in round-robin fashion. Paths should be separated by colon characters (“:”) on Unix and semicolon characters (“;”) on Windows, NetWare, and OS/2. If the MySQL server is acting as a replication slave, you should not set &#8211;tmpdir to point to a directory on a memory-based file system or to a directory that is cleared when the server host restarts. For more information about the storage location of temporary files, see Section A.1.4.4, “Where MySQL Stores Temporary Files”. A replication slave needs some of its temporary files to survive a machine restart so that it can replicate temporary tables or LOAD DATA INFILE operations. If files in the temporary file directory are lost when the server restarts, replication fails. </p></blockquote>
<blockquote cite="http://dev.mysql.com/doc/refman/4.1/en/temporary-files.html"><p>On Unix, MySQL uses the value of the TMPDIR  environment variable as the path name of the directory in which to store temporary files. If TMPDIR  is not set, MySQL uses the system default, which is usually /tmp, /var/tmp, or /usr/tmp. </p>
<p> If the file system containing your temporary file directory is too small, you can use the &#8211;tmpdir option to mysqld to specify a directory in a file system where you have enough space.</p>
<p>Starting from MySQL 4.1, the &#8211;tmpdir option can be set to a list of several paths that are used in round-robin fashion. Paths should be separated by colon characters (“:”) on Unix and semicolon characters (“;”) on Windows, NetWare, and OS/2.<br />
Note</p>
<p>To spread the load effectively, these paths should be located on different physical disks, not different partitions of the same disk.</p>
<p>If the MySQL server is acting as a replication slave, you should not set &#8211;tmpdir to point to a directory on a memory-based file system or to a directory that is cleared when the server host restarts. A replication slave needs some of its temporary files to survive a machine restart so that it can replicate temporary tables or LOAD DATA INFILE operations. If files in the temporary file directory are lost when the server restarts, replication fails.</p>
<p>MySQL creates all temporary files as hidden files. This ensures that the temporary files are removed if mysqld is terminated. The disadvantage of using hidden files is that you do not see a big temporary file that fills up the file system in which the temporary file directory is located.
</p></blockquote>
<p><br class="C" /></p>
<h2>Shell Script for Firefox tmpfs</h2>
<pre>#!/bin/bash
### Bind temporary directories to /dev/shm ###
# I do this instead of mounting tmpfs on the #
# directories, so less memory gets wasted.   #
##############################################
mkdir /dev/shm/{tmp,lock}
mount &#45;-bind /dev/shm/tmp /tmp
mount &#45;-bind /dev/shm/tmp /var/tmp
mount &#45;-bind /dev/shm/lock /var/lock
chmod 1777 /dev/shm/{tmp,lock}</pre>
<hr />
<p><strong>Hey!</strong> You made it!@ at least to the bottom of the page..  I still have to finish this article, so check back in a few months.</p>
<p><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html"></a><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html">30x Faster WP-Super Cache Site Speed</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/web-hosting/super-speed-secrets.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PortaPutty Auto-Reconnecting SSH Tunnels on an Encrypted TrueCrypt Portable USB Key w GPG</title>
		<link>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html</link>
		<comments>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html#comments</comments>
		<pubDate>Tue, 23 Feb 2010 10:11:11 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Making Money]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[401]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bash_profile]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Defrag]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[GPG]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[PageDefrag]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Pipelining]]></category>
		<category><![CDATA[Plink]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[SOCKS]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSH Tunnels]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[TrueCrupt]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[USB Drives]]></category>

		<guid isPermaLink="false">http://askapache.com/?p=4001</guid>
		<description><![CDATA[<p><a class="IFL" id="id6" href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a>Ok I just came back up to write the intro.. I'm trying to keep it short to avoid getting bogged down by the coolness of each step.  Here is what goes on.   When I logon to my XP machine at work, I bring my usb key and plug it in first.  On logging a window pops up first and it's a password prompt to mount my encrypted drive leonardo.  It also checks a keyfile that is located on my usb key, but all I do now is type in my password.  That causes my encrypted folder to be accessible to me like a normal drive, and it autoruns a startup batch file. <br /><br />The batch file causes <strong>Portable</strong> versions of Firefox (<em>all my bookmarks, my settings</em>) to load, and launches <strong>Portable</strong> Mozilla Thunderbird (IMAP makes this work well), which is my favorite program (<em>great GPG features and open-source!</em>).  Also Some Adobe CS4 software is loaded from the hard drive, like DreamWeaver.  In the background, a service we created executes a PortaPuttY plink command to create forwarded tunnels from various remote servers and accounts, all using key-based encryption.  These tunnels are automatically reconnected if they are disconnected, meaning you can use a socks 5 if you want or even better!<br class="C" /></p>
<p><strong>Part 1 of 5</strong></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=4329073&#038;CatId=3786" rel="nofollow" id="id6" class="IFL"  title="This ones over $400 dollars! 128GB!"></a>Ok I just came back up to write the intro.. I&#8217;m trying to keep it short to avoid getting bogged down by the coolness of each step.  Here is what goes on.   When I logon to my XP machine at work, I bring my usb key and plug it in first.  On logging a window pops up first and it&#8217;s a password prompt to mount my encrypted drive leonardo.  It also checks a keyfile that is located on my usb key, but all I do now is type in my password.  That causes my encrypted folder to be accessible to me like a normal drive, and it autoruns a startup batch file.  The batch file causes <strong>Portable</strong> versions of Firefox (<em>all my bookmarks, my settings</em>) to load, and launches <strong>Portable</strong> Mozilla Thunderbird (IMAP makes this work well), which is my favorite program (<em>great GPG features and open-source!</em>).  Also Some Adobe CS4 software is loaded from the hard drive, like DreamWeaver.<br class="C" /></p>
<p>The batch file also runs PortaPuttY plink to create forwarded tunnels from various remote servers and accounts, all using key-based encryption.  This includes dynamic SOCKS 4/5 tunnels, VPN tun device tunnels, and of course the basic SSH port forwarding tunnels that are so powerful.  These tunnels are automatically reconnected if they are disconnected, using simple windows builtin command-line tools.  And believe me it was not easy to figure out how to make this all work using plink ( essentially the same as putty minus the gui ), I literally had to use almost all of my Windows kung fu to finally end up with this.</p>
<h2>Using MyEnTunnel</h2>
<p>Initially I was using the <a href="http://nemesis2.qx.net" rel="nofollow" >MyEnTunnel</a> program combined with a custom windows batch install script I wrote to handle the tunnels.</p>
<p>The tunnels are very important to making things easy while improving security.  It&#8217;s not easy to understand at first, but basically it means <strong>you can now connect to ANY IP address:port as if you were on that very machine connecting to localhost, like if you pinged yourself!</strong>.  The result is any traffic you want is now encrypted, and you can set up your servers to only accept connections from localhost, which could save you tons of memory, bandwidth, and security attack vectors to think about.   So I configure everything to use these tunnels as proxies, like Mozilla Thunderbird and Chrome, Firefox, Pidgeon, all portable versions and running from my encrypted usb drive.</p>
<p>This means you can walk into my house with that usb key, plug into any computer here, and surf the web/check your emails all across SSH&#8230; I know for a fact <strong>I wouldn&#8217;t be able to snoop that</strong> traffic!  There is a lot of exciting things going on around here, new servers and all.. Its going to take a couple more posts for me to finish this up, enjoy the article and comment.</p>
<h2>Buy a couple USB Mini Drives</h2>
<p>The first thing to do, is purchase a USB thumb drive..   My favorite store, <a href="http://www.tigerdirect.com/applications/category/category_slc.asp?Recs=30&#038;Nav=|c:379|lp:0.01:hp:24.99|&#038;Sort=4" rel="nofollow"  title="Highly recommended, this is not an affiliate link">TigerDirect.com</a>, has over 104 tiny usb drives for under $24.. I&#8217;ve used them since the late 90&#8242;s.</p>
<p>I bought some 4GB PNY&#8217;s the size of a fingernail at a gas station and they are amazing, way faster than say a dvd drive.  Just try to do some research of the differences between the 16GB vs the $4 1GB drives.. You want speed because the whole drive will be encrypted.   <em>If you can afford the super excellent and crazy fast ones, hey send me one!</em> Buying cheap means you can buy 3 or 4 so you can always have backups.  This device will make you Internationally mobile, untethered from a box, maybe getting some work done at a cafe in Florenze, or at a beach hotel in Miami.  Keep dreaming, but that is more possible with a better organized system.</p>
<h3>Backup the USB Drive</h3>
<p>You only need to know 1 way that works, there are several.  The way I do backups is to copy the entire disk image of the usb, that way I can always access it in case of usb key failure, which does happen.  Free software like <a href="http://clonezilla.org/" rel="nofollow" >CloneZilla live CD</a> with its crazy cluster computing power, or Self Image, which is free for both linux and Windows.  And you could never go wrong with <a href="http://www.symantec.com/norton/ghost" rel="nofollow" >GHOST</a>, one of the first to make mega bucks in the market.. it&#8217;s some seriously impressive software <em>but not open-source</em>.  Even easier for some is to just set a cron job for dd to pipe the entire drive image to a remote computer using netcat, or sshfs, or curlftpfs, or just <strong>simple ssh</strong> like below.  Once setup (without stupid, bulky, dangerous software), the files on your encrypted usb don&#8217;t change often, otherwise I would want to sync a backup to happen automatically every X number of logins or days (<em>test logfile time in bash_profile?</em>)..</p>
<h4>SSH Back-ups To Remote Server</h4>
<p>Files and data on your drives slow it down tremendously, meaning a web server storing backups locally is slower than one storing them externally.</p>
<p>Notice how much safer this command is by optimizing both the <a href="http://www.askapache.com/linux-unix/optimize-nice-ionice.html">CPU and DISK I/O</a>..  Though it&#8217;s much smarter to create a new separate ssh user, one with no shell and a passwordless safer key-based encryption.  Then in your /etc/security/limits.conf file or your initscript you can cause that user to have <code>nice -19</code> and <code>ionice -c2 -n7</code> priority set all the time automatically, since sshd, compression, and disk writing are this accounts only job.  turboslow is an alias defined in a ssh_config file so you don&#8217;t have to type the host, port, and settings each time.</p>
<pre>#
# much better ways to do this on google!!!!!!!
#
ionice -c2 -n7 nice -n 19 dd if=/dev/sdb2 bs=1k conv=sync,noerror | gzip -c | ssh turboslow &quot;dd of=sdb2.gz bs=1k&quot;</pre>
<p>Note that you may decide it would be better to configure the ssh connection to a less CPU intensive algorithm, perhaps even <em>protocol 1</em> and <em>DES</em>.  That&#8217;s perfectly alright, but the tradeoff is that the encryption can be broken much quicker, and so you would have to implement a cron job to create new keys on both ends of the tunnel every few hours.. It&#8217;s really not a big deal to setup, kind of sweet way to use key-based encryption.  Also, important files ( those containing passwords, any database ) are encrypted before transport using private GPG keys, which don&#8217;t need to be changed.  The other thing to think about too is only letting your main PC send/write on the backup host, so the backup host is only authorized to rx and can never login back to yours. </p>
<p>Hey! the Internet is a dangerous place you better believe it!  And it&#8217;s only going to get more interesting with cloud computing&#8217;s breakthrough&#8217;s&#8230; More people who know they&#8217;re way around&#8230; I can always use an extra server, I&#8217;d love to expand my network another node without having to pay for it (free cloud computing?), so make sure your servers are locked up strenuously.  Not super perfect, just a little unique or creative in your defense to avoid any coming super-worm&#8217;s that may be employing vast arsenals of the deadliest attack-engines like metasploit..  Scarry rumors.</p>
<h4>Compression Speeds: PBZip2, Rzip, Lzop, Gzip</h4>
<p>Probably the fastest is to use rsync over ssh, which is what I&#8217;m doing, since the algorithms used by rsync are much faster and safer.  <a href="http://www.askapache.com/security/mirror-using-rsync-ssh.html">Rsync also lets you specify a compression program</a>, so depending on your machine you will want pbzip2 (for multi processors) or rzip which are the 2 fastest I know of, though I have had some reliability issues with rzip for gigabyte transfers.  Pbzip2 is amazing, blew me away the first time being 8x faster (8 CPUs) then <strong>anything</strong>.  You can get it and compile a static binary for your thumb drive if want at <a href="http://compression.ca/pbzip2/" rel="nofollow" >Parallel BZIP2 (PBZIP2)</a>. Heavy code, re: this note by Jeff Gilchrist</p>
<p><quote><strong>NOTE</strong>: If you are looking for a parallel BZIP2 that works on cluster machines, you should check out <strong>MPIBZIP2</strong> <strong>which was designed for a distributed-memory message-passing architecture</strong>.</quote></p>
<pre>tar cpf &quot;$G&quot; &#45;-use-compress-prog=pbzip2 ./</pre>
<p><a href="http://uploads.askapache.com/2010/02/pbzip2.gif" rel="nofollow" ><img src="http://uploads.askapache.com/2010/02/pbzip2.gif" alt="Parallel BZIP2 (PBZIP2)" title="pbzip2" class="size-medium wp-image-4002" /></a></p>
<h4>Benchmarking for Performance</h4>
<p>Finally a couple tips, you should get an idea what the device can do, format it a few times for linux and test it on windows, and vice versa.. Some drives are too small or too old and can only support fat32 filesystems on winblows, you DO NOT want fat32 because this drive is going to be 100% encrypted and then 100% transparently decrypted as you use it, </p>
<pre># note this is 512MB
dd if=/dev/sda1 of=/dev/null bs=512 count=1000000
512000000 bytes (512 MB) copied, 5.16588 s, 99.1 MB/s</pre>
<h2>Part II:  Encrypted AutoRunning USB Key with TrueCrypt</h2>
<p>Now this section anyone can do, it&#8217;s so easy on Windows.   What I&#8217;m going to show you how to do is get setup the right way super-fast.  There are many ways to use TrueCrypt, it&#8217;s one of the nicest built software programs&#8217;s I&#8217;ve ever used&#8230; Sadly, it is not licensed open-source, and that is often a deal-breaker for security-conscious folks or anti-pirate anarchists.  From the very helpful TrueCrypt web site:</p>
<blockquote cite="">
<ul type="disc">
<li>Creates a <strong>virtual encrypted disk</strong> within a file and mounts  it as a real disk. </li>
<li>Encrypts an<strong> entire partition or storage device</strong> such as USB flash drive or hard drive.</li>
<li>Encrypts a <strong>partition or drive where Windows is installed</strong> (<a href="http://www.truecrypt.org/docs/?s=system-encryption" rel="nofollow" >pre-boot authentication</a>).</li>
<li>Encryption is <a href="http://www.truecrypt.org/docs/" rel="nofollow" ><strong>automatic</strong>, <strong>real-time</strong> (on-the-fly) and <strong>transparent</strong></a>.</li>
<li> <a href="http://www.truecrypt.org/docs/?s=parallelization" rel="nofollow" >Parallelization</a> and <a href="http://www.truecrypt.org/docs/?s=pipelining" rel="nofollow" >pipelining</a> allow data to be read and written as fast as if the drive was not encrypted.</li>
<li>Provides <strong><a href="http://www.truecrypt.org/docs/?s=plausible-deniability" rel="nofollow" >plausible deniability</a></strong>, in case an adversary  forces you to reveal the password: <strong><a href="http://www.truecrypt.org/hiddenvolume" rel="nofollow" >Hidden volume</a></strong> (steganography) and <strong><a href="http://www.truecrypt.org/docs/?s=hidden-operating-system" rel="nofollow" >hidden operating system</a></strong>.</li>
<li><a href="http://www.truecrypt.org/docs/?s=encryption-algorithms" rel="nofollow" >Encryption algorithms</a>: <a href="http://www.truecrypt.org/docs/?s=aes" rel="nofollow" >AES-256</a>, <a href="http://www.truecrypt.org/docs/?s=serpent" rel="nofollow" >Serpent</a>, and <a href="http://www.truecrypt.org/docs/?s=twofish" rel="nofollow" >Twofish</a>.  Mode of operation: <a href="http://www.truecrypt.org/docs/?s=modes-of-operation" rel="nofollow" >XTS</a>.</li>
</ul>
</blockquote>
<h2>Further Reading</h2>
<ul>
<li><a href="http://ultra.ap.krakow.pl/~bar/DOC/ssh_backup.html" rel="nofollow" >Network File Copy using SSH</a></li>
<li>Check out the trunk version of PuTTY:<code>~ svn co svn://svn.tartarus.org/sgt/putty</code>
</ul>
<hr class="C" />
<p>The real fun doesn&#8217;t start till all the automation starts, automating all of that from a couple batch files I wrote, one click setup.  Kind of like building your own knoppix for when you have to use Windows.  To begin this tutorial, setup a truecrypt traveller setup on your usb and also install the portaputty package onto the usb.  You do this by creating a 3GB or whatever file on the usb and then mounting that file like you would mount an iso file.   I will show the Windows Batch file I use and the tricks with Windows Volume names and how to consistently make it all work.   Then we will setup MyEnTunnel with a customized batch file that forces all puttys to use portaputty (<code>sweet hack stolen from sysinternals pagedefrag tool</code>).<strong>Stay Tuned!</strong></p>
<p><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html">PortaPutty Auto-Reconnecting SSH Tunnels on an Encrypted TrueCrypt Portable USB Key w GPG</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Optimize a Website for Speed, Security, and Easy Management</title>
		<link>http://www.askapache.com/htaccess/optimize-website-files-cache-security.html</link>
		<comments>http://www.askapache.com/htaccess/optimize-website-files-cache-security.html#comments</comments>
		<pubDate>Fri, 19 Feb 2010 00:45:26 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[301 Redirect]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[apache server]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[bleeding edge]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[Cache-Control]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[Etags]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[expires header]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[File Permissions]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[htaccess files]]></category>
		<category><![CDATA[Htpasswd]]></category>
		<category><![CDATA[HTTP Error]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[HTTP Status Codes]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[optimizations]]></category>
		<category><![CDATA[optimized website]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[password protection]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[real deal]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Redirection]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[search and replace]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[server config]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[SymLinks]]></category>
		<category><![CDATA[trial and error]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=1380</guid>
		<description><![CDATA[<p><a href="http://www.askapache.com/htaccess/optimize-website-files-cache-security.html" class="IFL hs hs37" title="Discover how to setup and manage a website from top to bottom for optimized speed, security, and simplicity"></a>Learn how to setup, configure, secure, optimize, and create a low-maintenance website the AskApache way.  I'm piecing together all the hacks, tricks, methods, and ideas discussed throughout this blog and all across Netdom and glueing them all together to show you how to have the most optimized, crazy fastest, and best website setup I can think of.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><img class="IFL" src="http://uploads.askapache.com/2008/09/computerimg.jpg" alt="optimized server setup" title="optimized server setup" />Over the past 10 or so years I&#8217;ve been directly or indirectly involved in configuring/administrating/hacking thousands of websites, and I realized today that I&#8217;ve actually learned quite a bit about how to really make them work hard for me, instead of the other way around. It came as a mild shock to think of where I was back then vs. now because the improvements and optimizations are hundreds of smaller improvements, but taken together, the  optimization hacks I&#8217;ve found through trial and error and much reading are as Donald would say, <strong>YOOUUGE</strong> compared to a basic website setup.<br class="C" /></p>
<p class="cnote">I use this awesome skeleton setup for all my high-paying clients <em>sorry poor people!</em> and also of course on this blog, which I use as a bleeding-edge dev server for my crazy testing.  So realize that I&#8217;m already past this setup and using it to do cooler stuff.  In order for you to use these more advanced ideas, you first need to get up to speed on what I&#8217;m doing so you know what I&#8217;m talking about.  This article tries to help you accomplish that&#8230; remains to be seen.</p>
<h2>An Optimized Website, The Real Deal</h2>
<p>This first article is to give you some ideas and get you thinking and reading before the first article in this series comes out.  This series details how to setup, configure, secure, optimize, and manage a website the best possible way I can come up with.  It pieces together all the AskApache hacks and tricks and uses methods and ideas discussed all over this blog and all over the net and glues them all together to show you how to have the most optimized, fastest, best website setup I can think of.</p>
<p>Knowing the why and how behind the operation of a Web Server allows us to optimize that operation.  For this example we will be creating the website <code>www.askapache.com</code>, which will be running WordPress and php.  We will also set up <code>static.askapache.com</code> to serve all of our sites uploads, images, css and javascript files, flash files, etc. with advanced caching and security using Apache Server .htaccess files.  So lets get started and take a look at this site structure for a moment.</p>
<pre>/home/askapache.com
|&#45;- /home/askapache.com/backups/
|&#45;- /home/askapache.com/public_html/
|&#45;- /home/askapache.com/inc/
|&#45;- /home/askapache.com/logs/
|&#45;- /home/askapache.com/static/
|&#45;- /home/askapache.com/tmp/
|&#45;- /home/askapache.com/.htpasswd-basic
`&#45;- /home/askapache.com/.htpasswd-digest</pre>
<ul>
<li><code>/backups/</code> &#8211; For <a href="http://www.askapache.com/wordpress/encrypted-wordpress-site-backups.html">encrypted backups of WordPress database and site files</a>. And any other backups.</li>
<li><code>/public_html/</code> &#8211; The document root for <code>www.askapache.com</code></li>
<li><code>/inc/</code> &#8211; Folder to keep your php include files for extra security and easy management.</li>
<li><code>/logs/</code> &#8211; Save your php, apache, and other logs here or create symlinks to them.</li>
<li><code>/static/</code> &#8211; The document root for <code>static.askapache.com</code></li>
<li><code>/tmp/</code> &#8211; Only need this if your host doesn&#8217;t already have a /tmp folder</li>
</ul>
<hr class="HR0" />
<h2>Strong Security, Top to Bottom</h2>
<p><img class="IFL" src="http://uploads.askapache.com/2008/09/1023103_warning_icon_32.jpg" width="150" alt="Optimize a Website for Speed, Security, and Easy Management" title="Site Security with Apache" />Simply by implementing correct access permissions, file permissions, password protection and segmenting various folders and services we are already ahead of the game.  I&#8217;ve always taken security extremely seriously, so you can benefit from alot of the simple solutions I&#8217;m recommending for a really locked down site.<br class="C" /></p>
<p>Indeed, security is a major part of every step of this setup process, as security concerns are what drives a lot of the motivations I have for coming up with this setup in the first place.  We will be doing very simple but very effective site security like the following items, which is a short list compared to everything we will be doing.</p>
<ul>
<li>Fixing file permissions automatically</li>
<li>Searching for modified files on the server</li>
<li>Encrypting your backups</li>
<li>Get alerted to breakin attempts</li>
<li>Block tons of bad clients</li>
<li>Disallowing cgi scripts or any other handlers, just serve files.</li>
<li>Configuring PHP</li>
<li>Password Protection for certain areas</li>
</ul>
<h3>Ready for Warfare?</h3>
<p>My past work for an Internet Service Provider, followed by 4 years of auditing the security of organizations external/internal networks has given me a fresh perspective on website security, and I think it allows me to see what would really be effective at preventing and killing attacks.  In fact just last night I was once again doing some research into some off-the-wall security topics, and I discovered a new defense method that I will be writing about very soon.  I believe that this new method,  could be quickly adopted and implemented by hosting providers and software developers, which would result in us finally taking the Internet back from all those zombies and robots.  This method will be discussed in great detail soon, and will be a core part of this site setups security and optimization.</p>
<hr class="HR0" />
<h2>Built to <span style="color:red">Bleed Speed</span></h2>
<p><img class="IFL" src="http://uploads.askapache.com/2008/09/speedontheroadimg.jpg" width="150" alt="Optimize a Website for Speed, Security, and Easy Management" title="326255_speed_on_the_road" />Serve&#8217;s files as fast and efficiently as possible using advanced caching, HTTP Protocols, php/server configurations.<br class="C" /></p>
<p>Many of the articles and research on this blog is about improving the speed and efficiency of your website.  In fact that is why I am helping develop open-source software to block spammers from WordPress blogs&#8230; not because I&#8217;m bothered by the spam, but because they make the net slow!  So lets look at some of the ideas we&#8217;ll be implementing.</p>
<p>Many techniques I&#8217;ve been using and tweaking for several years, and recently many of them were included in the high-performance websites list.  Of course we will be taking a look at this list in practical terms, meaning almost all of it, the caching, compression, etc., will be automated in keeping with our &#8220;comfort&#8221; goal, which is to say we want to make the Web Developer and Server Admin&#8217;s lives as easy and comfy as possible.  After all, we do the work right?</p>
<ol>
<li>Reduce HTTP requests &#8211; <a href="http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html" title="304 If Modified article">Reducing 304 requests with Cache-Control Headers</a></li>
<li>Use a customized php.ini &#8211; <a href="http://www.askapache.com/php/custom-phpini-tips-and-tricks.html">Creating and using a custom PHP.ini</a></li>
<li>Add an Expires header &#8211; <a href="http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html#caching-with-mod_expires" title="mod_expires Caching article">Caching with mod_expires on Apache</a></li>
<li>Gzip components</li>
<li>Make CSS and unobtrusive Javascript as external files not inline</li>
<li>Reduce DNS lookups &#8211; Use Static IP address, use a subdomain with static IP address for static content.</li>
<li>Minimize Javascript &#8211; Refactor the code, compress with <a href="http://dojotoolkit.org/docs/shrinksafe" rel="nofollow" >dojo</a></li>
<li>Avoid external redirects &#8211; <a href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html" title="mod_rewrite internal redirection and rewrites">Use internal redirection with mod_rewrite</a>, <a href="http://www.askapache.com/htaccess/301-redirect-with-mod_rewrite-or-redirectmatch.html" title="301 Redirect with mod_rewrite or RedirectMatch">The correct way to redirect with 301</a></li>
<li>Turn off ETags &#8211; <a href="http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html#prevent-caching-with-htaccess">Prevent Caching with htaccess</a></li>
<li>Make AJAX cacheable and small</li>
</ol>
<h3>AskApache.com, Fastest Site Ever!</h3>
<p>Ok it <em>might</em> not be the #1, but surely the top 10.. ;)</p>
<p>I&#8217;m very proud of the performance I am able to achieve on this site.  Very proud.  I started looking for ways to improve the wp-cache and wp-super-cache WordPress plugins, and came up with hacks for both of them.. but they still didn&#8217;t do what I wanted so I started from scratch and wrote my own caching plugin.</p>
<p>With much more advanced caching options and unquestionably higher performance and lower time usage on the machine.  I&#8217;m hesitant to release it to the public until I get faded on it.. I just really love it.. it has been running my site for several months now and I keep finding ways to improve it.. Stay tuned.</p>
<p>One feature it has is the ability to allow negotiation of a resource between apache and the client.  Think almost transparent mutli-lingual blogs, mutliple formats per document (look at the rdf for this page for an example*). But that plugin is the future and this is the present.. so back to it we go.</p>
<hr class="HR0" />
<h2>Pamper the Webmaster with Extreme Comfort</h2>
<p><img class="IFL" src="http://uploads.askapache.com/2008/09/wwwonthebeachimg.jpg" width="150" alt="Optimize a Website for Speed, Security, and Easy Management" title="Low Maintenance Web Development" />This section alone would make this setup appealing.  I have developed all types of techniques and methods to make my life as easy as possible.  I could literally DIE right now and this blog would continue to run and operate for years on its own.   The general philosophy that I have used to get to where I can goto the beach with my laptop and do all this crazy stuff is <strong>the idea of perfection</strong>.  That may sound a little put-offish, but it basically means I will focus in on one very specific area for improvement or research and just get sick with it.  Most of this blogs articles are enlightening examples of this in action.  I will take a relatively unknown or unused piece of code or software and experiment with it until I feel I have it down, then I move on to the next item of never-ending research.  Mostly I think this is just plain habit from when I was studying security.  I&#8217;m much better at this then that :)</p>
<h3>Apache ErrorDocuments</h3>
<p>The <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">57 HTTP Status Codes and Apache ErrorDocuments</a> article is a prime example.  I was simply searching for an authoritative list of HTTP status codes, an issue not many web people find worth their time, and that search led to some of the most useful stuff I&#8217;ve found about the Web</p>
<p>This &#8220;Comfort&#8221; article will include multi-language, intelligent, and optimized error documents for handling any type of HTTP error with class and allow us to stop spammers, save bandwidth, redirect correctly, etc..  You will probably be surprised at all the uses an Apache ErrorDocument can have.. It IS one of the foundations of the HTTP-based Net after all.<br class="C" /></p>
<h3>Emphasis on Easy Upgrades</h3>
<p>The whole setup is geared to make hassle-free WordPress/PHP/application upgrades possible by keeping different types of files in separate places, keeping backups, other misc tricks and since all of these files are in /home/askapache.com, your FTP connection can still access every file easily.  Sometimes security and optimizing your server can lead to it being more of a pain to do updates, backups, and general maintenance.  This article tries to overwhelm the balance with a trifecta of goals.</p>
<h3>Move to a new host? Ok!</h3>
<p>Comfort to me also means being able to pack up the whole website and database and move to another web host in under an hour.  I can move the whole AskApache site to one of several other hosting providers accounts I have in about 30minutes.  If this was a clients site or I was getting paid more, I&#8217;d also be focused on round-robin DNS technology, balance-load setups, and just go crazy making it fast.</p>
<h3>Staying Online, Improving Uptime</h3>
<p>Ever since I started sharing information and software to stop all these resource hogging zombies attacking everything I&#8217;ve been attacked several times.  Normally I get over 10K exploit attempts or requests per day, which I pretty much block 100%.  But a few times they&#8217;ve actually tried to DDOS me off the net in a distributed attack.  I have implemented several &#8220;poor mans&#8221; techniques to put up your best effort at surviving, which I did.  Basically you want to configure your server to KILL connections just as fast as possible and prevent your server resources from skyrocketing and surpassing your quotas.  A skilled attacker could easily shut you down even without the use of a widespread botnet if they are clever, which could be devastating to your small blog or site if it goes down at a crucial instant.</p>
<hr class="HR0" />
<h2>Organization with Templates and Systems</h2>
<p>I used to work with a guy who did alot of the coldfusion programming for us, and I used to cringe every  time I was called in to upgrade a site or do a re-design.  Files and folders EVERYWHERE!  Literally images in every folder, multiple index.html, index1.html, index-old.html, and on and on it went.. It would take me hours just to reverse-engineer the site enough so I could modify files on it without having some unkown consequence happen.</p>
<h3>Do You Have a Cluttered Desktop?</h3>
<p>Everyone has this problem, what I do all the time is just grab everything on my desktop and put it in a folder named with the date.  Then the process repeats itself and invariably a few months later I&#8217;m looking at a cluttered screen again.</p>
<p>This absolutely is the worst thing that can happen to a website, worst for security, comfort for webmaster, and speed.  So this setup addresses that issue completely heads on.  With all the different pages, tools, and resources available on this blog, I can almost promise you that my site has less files than yours.  No small feat to be sure, but worth every second I spent researching how to do it now that its on and popping.</p>
<hr class="HR0" />
<h2>What&#8217;s a Website really?</h2>
<p>All hosts are different, but any host worth their salt is running some kind of <a href="http://www.askapache.com/linux-unix/">BSD/Linux</a> operating system, and that is good news because those operating systems all use very similarly excellent file/folder structures with huge organization systems.  If your web hosting provider is running on a Windows based operating system or other locked/proprietary software than this article is not for you and I would recommend switching hosts to a BSD/Linux open-source operating system.</p>
<h3>Listening for Requests with Web Hosting and DNS</h3>
<p>First you set your website up so it can start serving.</p>
<ol>
<li>You buy your domain name, which just gives you the right to use it.</li>
<li>You pay your webhost for an account on their machine running a Server connected to the Net <em>via a fast connection link</em>.</li>
<li>You pay a DNS provider to redirect requests for your domain  name to be sent to your webhosts machine running the server.</li>
</ol>
<h2>Sub-Domain for Serving Assets</h2>
<p>This is a very cool method I&#8217;ve been using more and more frequently because it makes updates, upgrades, and changes so much easier to manage.  And segmenting various parts of the site is smart security, and even smarter in the way of speeding up a website and keeping your <strong>servers running mean and lean</strong>.</p>
<h2>Full Site Structure Expanded</h2>
<pre>/home/askapache.com
|&#45;- /home/askapache.com/backups/
|&#45;- /home/askapache.com/public_html/
|   |&#45;- /home/askapache.com/public_html/about/
|   |&#45;- /home/askapache.com/public_html/admin/
|   |&#45;- /home/askapache.com/public_html/cgi-bin/
|   |&#45;- /home/askapache.com/public_html/.htaccess
|   |&#45;- /home/askapache.com/public_html/index.php
|   `&#45;- /home/askapache.com/public_html/robots.txt
|&#45;- /home/askapache.com/inc/
|   |&#45;- /home/askapache.com/inc/config.inc.php
|   `&#45;- /home/askapache.com/inc/settings.inc.php
|&#45;- /home/askapache.com/logs/
|   |&#45;- /home/askapache.com/logs/access.log
|   |&#45;- /home/askapache.com/logs/error.log
|   |&#45;- /home/askapache.com/logs/logins.log
|   |&#45;- /home/askapache.com/logs/modsec_audit.log
|   |&#45;- /home/askapache.com/logs/modsec_debug.log
|   `&#45;- /home/askapache.com/logs/php_error.log
|&#45;- /home/askapache.com/static/
|   |&#45;- /home/askapache.com/static/css/
|   |&#45;- /home/askapache.com/static/flv/
|   |&#45;- /home/askapache.com/static/img/
|   |&#45;- /home/askapache.com/static/js/
|   |&#45;- /home/askapache.com/static/mp3/
|   |&#45;- /home/askapache.com/static/pdf/
|   |&#45;- /home/askapache.com/static/swf/
|   |&#45;- /home/askapache.com/static/.htaccess
|   |&#45;- /home/askapache.com/static/index.html
|   `&#45;- /home/askapache.com/static/robots.txt
|&#45;- /home/askapache.com/tmp/
|&#45;- /home/askapache.com/.htpasswd-basic
`&#45;- /home/askapache.com/.htpasswd-digest</pre>
<h2>Full Expanded Structure</h2>
<pre>/home/askapache.com
|&#45;- /home/askapache.com/backups/
|&#45;- /home/askapache.com/public_html/
|   |&#45;- /home/askapache.com/public_html/about/
|   |   `&#45;- /home/askapache.com/public_html/about/index.html
|   |&#45;- /home/askapache.com/public_html/admin/
|   |   |&#45;- /home/askapache.com/public_html/admin/.htaccess
|   |   `&#45;- /home/askapache.com/public_html/admin/index.html
|   |&#45;- /home/askapache.com/public_html/cgi-bin/
|   |   |&#45;- /home/askapache.com/public_html/cgi-bin/bin/
|   |   |   |&#45;- /home/askapache.com/public_html/cgi-bin/bin/.htaccess
|   |   |   |&#45;- /home/askapache.com/public_html/cgi-bin/bin/php.cgi*
|   |   |   |&#45;- /home/askapache.com/public_html/cgi-bin/bin/php.ini
|   |   |   |&#45;- /home/askapache.com/public_html/cgi-bin/bin/php4.cgi*
|   |   |   `&#45;- /home/askapache.com/public_html/cgi-bin/bin/php5.cgi*
|   |   |&#45;- /home/askapache.com/public_html/cgi-bin/private/
|   |   |   |&#45;- /home/askapache.com/public_html/cgi-bin/private/.htaccess
|   |   |   |&#45;- /home/askapache.com/public_html/cgi-bin/private/debug.php
|   |   |   `&#45;- /home/askapache.com/public_html/cgi-bin/private/stats.php
|   |   |&#45;- /home/askapache.com/public_html/cgi-bin/.htaccess
|   |   |&#45;- /home/askapache.com/public_html/cgi-bin/login.php
|   |   |&#45;- /home/askapache.com/public_html/cgi-bin/printenv.cgi*
&nbsp;
|   |   `&#45;- /home/askapache.com/public_html/cgi-bin/redir.cgi*
|   |&#45;- /home/askapache.com/public_html/.htaccess
|   |&#45;- /home/askapache.com/public_html/index.php
|   `&#45;- /home/askapache.com/public_html/robots.txt
|&#45;- /home/askapache.com/inc/
|   |&#45;- /home/askapache.com/inc/config.php
|   `&#45;- /home/askapache.com/inc/functions.php
|&#45;- /home/askapache.com/logs/
|   |&#45;- /home/askapache.com/logs/access.log
|   |&#45;- /home/askapache.com/logs/error.log
|   |&#45;- /home/askapache.com/logs/logins.log
|   |&#45;- /home/askapache.com/logs/modsec_audit.log
|   |&#45;- /home/askapache.com/logs/modsec_debug.log
|   `&#45;- /home/askapache.com/logs/php_error.log
|&#45;- /home/askapache.com/static/
|   |&#45;- /home/askapache.com/static/css/
|   |   `&#45;- /home/askapache.com/static/css/apache.css
|   |&#45;- /home/askapache.com/static/flv/
|   |   `&#45;- /home/askapache.com/static/flv/apache.flv
|   |&#45;- /home/askapache.com/static/img/
|   |   |&#45;- /home/askapache.com/static/img/apache.gif
|   |   |&#45;- /home/askapache.com/static/img/apache.jpg
|   |   `&#45;- /home/askapache.com/static/img/apache.png
|   |&#45;- /home/askapache.com/static/js/
|   |   `&#45;- /home/askapache.com/static/js/apache.js
|   |&#45;- /home/askapache.com/static/mp3/
|   |   `&#45;- /home/askapache.com/static/mp3/apache.mp3
|   |&#45;- /home/askapache.com/static/pdf/
|   |   `&#45;- /home/askapache.com/static/pdf/apache.pdf
|   |&#45;- /home/askapache.com/static/swf/
|   |   `&#45;- /home/askapache.com/static/swf/apache.swf
|   |&#45;- /home/askapache.com/static/.htaccess
|   |&#45;- /home/askapache.com/static/index.html
|   `&#45;- /home/askapache.com/static/robots.txt
|&#45;- /home/askapache.com/tmp/
|&#45;- /home/askapache.com/.htpasswd-basic
`&#45;- /home/askapache.com/.htpasswd-digest</pre>
<p>The buzz about apache and open-source is very real, apache is becoming more of a discussed topic as people realize the power and importance of <q cite="LL Cool J">Doing it and Doing it and Doing it well.</q> &#8211;  <small><a href="http://www.webmonkey.com/blog/Jumpbox_Offers_an_Easier_Way_to_Install_Movable_Type" rel="nofollow" >Movable Type Apache Installs made easy</a>, <a href="http://www.ubuntugeek.com/webalizer-apache-web-server-log-file-analysis-tool.html" rel="nofollow" >Checking out Apache Web logs</a>, <a href="http://eventurebiz.com/blog/securing-securing-your-wordpress-blog-post-6-protecting-the-wp-configphp-file/" rel="nofollow" >Securing WordPress with .htaccess</a>, <a href="http://marketingdefined.com/blog/wordpress/using-wordpress-permalink-redirect-plugins-correctly/" rel="nofollow" >WordPress Permalinks and .htaccess</a>, <a href="http://corpocrat.com/2008/09/19/install-apache-mod_substitute/" rel="nofollow" >New search and replace module for apache!</a>, <a href="http://www.csskarma.com/blog/creating-an-htaccess-template/" rel="nofollow" >creating an .htaccess template</a>, <a href="http://www.thelinuxblog.com/htaccess-allow-from/" rel="nofollow" >.htaccess allow directive</a></small></p>
<p class="anote">Check back in a week for the first article, or better yet subscribe to my <a href="http://www.askapache.com/feed/">rss feed</a> or use the comment form below to get notified.</p>
<p><a href="http://www.askapache.com/htaccess/optimize-website-files-cache-security.html"></a><a href="http://www.askapache.com/htaccess/optimize-website-files-cache-security.html">Optimize a Website for Speed, Security, and Easy Management</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/optimize-website-files-cache-security.html/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>HTTP Status Codes and .htaccess ErrorDocuments</title>
		<link>http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html</link>
		<comments>http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#comments</comments>
		<pubDate>Mon, 04 Jan 2010 20:56:15 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[301 Redirect]]></category>
		<category><![CDATA[302 Redirect]]></category>
		<category><![CDATA[401]]></category>
		<category><![CDATA[403 Forbidden]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[503]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[error log]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[HTTP Error]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[HTTP Status Codes]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[If-Modified-Since]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[phpBB]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Redirection]]></category>
		<category><![CDATA[Request Method]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Sniffing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Wget]]></category>
		<category><![CDATA[Wireshark]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/wow-i-served-a-page-for-every-single-http-status-code-and-saved-headers-and-content.html</guid>
		<description><![CDATA[<p>There are a total of <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-response-codes-57">57 HTTP Status Codes</a> recognized by the Apache Web Server.  Wouldn't you like to see what all those headers and their output, ErrorDocuments look like?</p>]]></description>
			<content:encoded><![CDATA[<p><strong>I was trying to find an official, authoritative list of HTTP Status Codes</strong> but I kept finding lists that weren&#8217;t authoritative or complete. So I searched and found my answer in the Apache HTTP Server source code.  Once I had the exact HTTP Status Codes and resulting Error Documents sent by Apache, I researched deeper into HTTP Status Codes by reading as many related RFC&#8217;s as I could find, and several other software source codes were explored.  This is the most authoritative list I know of, if you can do better leave a comment and I&#8217;ll update it.  Another thing to keep in mind, the Status code number itself is what is used by software and hardware to make determinations, the phrase returned by the status code is for the human only and does not have any weight other than informing the user.. So &#8220;503 Service Unavailable&#8221;, &#8220;503 Service Temporarily Unavailable&#8221;, and &#8220;503 Get the heck outta here&#8221; are all completely valid.</p>
<p class="bnote"><strong>Update March 9, 2009</strong>: A lot of sites on the web have updated their HTTP status code lists to include the HTTP Status codes listed on this page, including Wikipedia, IANA, W3C, and others, so rest assured this info is accurate and complete.  If you&#8217;d like to see how to create custom error pages for all of these errors like mine  <a href="http://www.askapache.com/show-error-506">/show-error-506</a> , then check out  <a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html">this detailed tutorial</a>  I just posted.</p>
<h2>Contents</h2>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-response-codes-57">List of All 57 HTTP Response Status Code</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#quick-start">Quick Start to triggering ErrorDocuments for each Status Code</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#automating-the-process">Automate the ErrorDocument Triggering</a>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#redirect-code-in-htaccess">The htaccess Code</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#php-header-grabber-script">PHP script that gets and outputs the Headers/Content</a> </li>
</ul>
</li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#headers-returned-content">Headers and Content Returned</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-source-code">Apache Source Code</a>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#httpdh-h">httpd.h</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#http_protocol-c">http_protocol.c</a> </li>
</ul>
</li>
</ul>
<h2> <a href="#apache-response-codes-57" rel="nofollow"  name="apache-response-codes-57" id="apache-response-codes-57">57 APACHE HTTP STATUS RESPONSE CODES</a> </h2>
<p>Once I compiled the list of Apache recognized HTTP Status Codes, I was dying to see them all in action (<em>i.e. the corresponding <strong>ErrorDocument</strong></em>).  At first I thought I would have to create a php or perl script emulating each of the 57 HTTP Status Codes, a tedious undertaking I wasn&#8217;t about to do.  Instead I &#8220;asked Apache&#8221; by searching the  <a href="http://httpd.apache.org/docs/trunk/" rel="nofollow" >Apache HTTP Documentation</a>  for <em>ambiguity sending Status Codes and/or triggering ErrorDocuments</em> with an Apache Directive.<br /><strong>While reading</strong> up on  <a href="http://askapache.info/trunk/mod/mod_alias.html" rel="nofollow" >mod_alias</a>  and the  <a href="http://askapache.info/trunk/mod/mod_alias.html#redirect" rel="nofollow" >Redirect</a>  directive I found:</p>
<blockquote cite="http://httpd.apache.org/docs/trunk/mod/mod_alias.html#redirect"><p><cite>Apache Docs</cite></p>
<p>Syntax: <strong>Redirect [status] URL-path URL</strong> The status argument can be used to return <strong>other</strong> HTTP status codes. <strong>Other</strong> status codes can be returned by giving the numeric status code as the value of status.  If the status is between 300 and 399, the URL argument must be present, otherwise it must be omitted.</p>
</blockquote>
<dl>
<dt><a id="code-100" title="Continue">100 Continue</a> </dt>
<dd><a href="/e/100/" rel="nofollow" title="ErrorDocument 100" >ErrorDocument Continue</a>  |  <a href="#status-100" rel="nofollow"  title="Sample Continue">Sample 100 Continue</a> <br />This means that the server has received the request headers, and that the client should proceed to send the request body (in case of a request which   needs to be sent; for example, a POST request). If the request body is large, sending it to a server when a request has already been rejected based upon inappropriate headers is inefficient.   To have a server check if the request could be accepted based on the requests headers alone, a client must send Expect: 100-continue as a header in its initial request (see RFC 2616 14.20 Expect header) and check if a 100 Continue status code is received in response before continuing (or receive 417 Expectation Failed and not continue).</dd>
<dt><a id="code-101" title="Switching Protocols">101 Switching Protocols</a> </dt>
<dd><a href="/e/101/" rel="nofollow" title="ErrorDocument 101" >ErrorDocument Switching Protocols</a>  |  <a href="#status-101" rel="nofollow"  title="Sample Switching Protocols">Sample 101 Switching Protocols</a> <br />This means the requester has asked the server to switch protocols and the server is acknowledging that it will do so.[3]</dd>
<dt><a id="code-102" title="Processing">102 Processing</a> </dt>
<dd><a href="/e/102/" rel="nofollow" title="ErrorDocument 102" >ErrorDocument Processing</a>  |  <a href="#status-102" rel="nofollow"  title="Sample Processing">Sample 102 Processing</a> <br />(WebDAV) &#8211; (RFC 2518 )</dd>
<dt><a id="code-200" title="OK">200 OK</a> </dt>
<dd><a href="/e/200/" rel="nofollow" title="ErrorDocument 200" >ErrorDocument OK</a>  |  <a href="#status-200" rel="nofollow"  title="Sample OK">Sample 200 OK</a> <br />Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an   entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action.</dd>
<dt><a id="code-201" title="Created">201 Created</a> </dt>
<dd><a href="/e/201/" rel="nofollow" title="ErrorDocument 201" >ErrorDocument Created</a>  |  <a href="#status-201" rel="nofollow"  title="Sample Created">Sample 201 Created</a> <br />The request has been fulfilled and resulted in a new resource being created.</dd>
<dt><a id="code-202" title="Accepted">202 Accepted</a> </dt>
<dd><a href="/e/202/" rel="nofollow" title="ErrorDocument 202" >ErrorDocument Accepted</a>  |  <a href="#status-202" rel="nofollow"  title="Sample Accepted">Sample 202 Accepted</a> <br />The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it   might be disallowed when processing actually takes place.</dd>
<dt><a id="code-203" title="Non-Authoritative Information">203 Non-Authoritative Information</a> </dt>
<dd><a href="/e/203/" rel="nofollow" title="ErrorDocument 203" >ErrorDocument Non-Authoritative Information</a>  |  <a href="#status-203" rel="nofollow"  title="Sample Non-Authoritative Information">Sample 203 Non-Authoritative Information</a> <br />The server successfully processed the request, but is returning information that may be from another source.</dd>
<dt><a id="code-204" title="No Content">204 No Content</a> </dt>
<dd><a href="/e/204/" rel="nofollow" title="ErrorDocument 204" >ErrorDocument No Content</a>  |  <a href="#status-204" rel="nofollow"  title="Sample No Content">Sample 204 No Content</a> <br />The server successfully processed the request, but is not returning any content.</dd>
<dt><a id="code-205" title="Reset Content">205 Reset Content</a> </dt>
<dd><a href="/e/205/" rel="nofollow" title="ErrorDocument 205" >ErrorDocument Reset Content</a>  |  <a href="#status-205" rel="nofollow"  title="Sample Reset Content">Sample 205 Reset Content</a> <br />The server successfully processed the request, but is not returning any content. Unlike a 204 response, this response requires that the requester   reset the document view.</dd>
<dt><a id="code-206" title="Partial Content">206 Partial Content</a> </dt>
<dd><a href="/e/206/" rel="nofollow" title="ErrorDocument 206" >ErrorDocument Partial Content</a>  |  <a href="#status-206" rel="nofollow"  title="Sample Partial Content">Sample 206 Partial Content</a> <br />The server is delivering only part of the resource due to a range header sent by the client. This is used by tools like wget to enable resuming   of interrupted downloads, or split a download into multiple simultaneous streams.</dd>
<dt><a id="code-207" title="Multi-Status">207 Multi-Status</a> </dt>
<dd><a href="/e/207/" rel="nofollow" title="ErrorDocument 207" >ErrorDocument Multi-Status</a>  |  <a href="#status-207" rel="nofollow"  title="Sample Multi-Status">Sample 207 Multi-Status</a> <br />(WebDAV) &#8211; The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests   were made.</dd>
<dt><a id="code-226" title="IM Used">226 IM Used</a> </dt>
<dd><a href="/e/226/" rel="nofollow" title="ErrorDocument 226" >ErrorDocument IM Used</a>  |  <a href="#status-226" rel="nofollow"  title="Sample IM Used">Sample 226 IM Used</a> <br />The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations   applied to the current instance.  The actual current instance might not be available except by combining this response with other previous or future responses, as appropriate for the specific   instance-manipulation(s).</dd>
<dt><a id="code-300" title="Multiple Choices">300 Multiple Choices</a> </dt>
<dd><a href="/e/300/" rel="nofollow" title="ErrorDocument 300" >ErrorDocument Multiple Choices</a>  |  <a href="#status-300" rel="nofollow"  title="Sample Multiple Choices">Sample 300 Multiple Choices</a> <br />Indicates multiple options for the resource that the client may follow. It, for instance, could be used to present different format options for   video, list files with different extensions, or word sense disambiguation.</dd>
<dt><a id="code-301" title="Moved Permanently">301 Moved Permanently</a> </dt>
<dd><a href="/e/301/" rel="nofollow" title="ErrorDocument 301" >ErrorDocument Moved Permanently</a>  |  <a href="#status-301" rel="nofollow"  title="Sample Moved Permanently">Sample 301 Moved Permanently</a> <br />This and all future requests should be directed to the given URI.</dd>
<dt><a id="code-302" title="Found">302 Found</a> </dt>
<dd><a href="/e/302/" rel="nofollow" title="ErrorDocument 302" >ErrorDocument Found</a>  |  <a href="#status-302" rel="nofollow"  title="Sample Found">Sample 302 Found</a> <br />This is the most popular redirect code[citation needed], but also an example of industrial practice contradicting the standard. HTTP/1.0 specification   (RFC 1945 ) required the client to perform a temporary redirect (the original describing phrase was &#8220;Moved Temporarily&#8221;), but popular browsers implemented it as a 303 See Other. Therefore,   HTTP/1.1 added status codes 303 and 307 to disambiguate between the two behaviours. However, the majority of Web applications and frameworks still use the 302 status code as if it were the   303.</dd>
<dt><a id="code-303" title="See Other">303 See Other</a> </dt>
<dd><a href="/e/303/" rel="nofollow" title="ErrorDocument 303" >ErrorDocument See Other</a>  |  <a href="#status-303" rel="nofollow"  title="Sample See Other">Sample 303 See Other</a> <br />The response to the request can be found under another URI using a GET method. When received in response to a PUT, it should be assumed that the   server has received the data and the redirect should be issued with a separate GET message.</dd>
<dt><a id="code-304" title="Not Modified">304 Not Modified</a> </dt>
<dd><a href="/e/304/" rel="nofollow" title="ErrorDocument 304" >ErrorDocument Not Modified</a>  |  <a href="#status-304" rel="nofollow"  title="Sample Not Modified">Sample 304 Not Modified</a> <br />Indicates the resource has not been modified since last requested. Typically, the HTTP client provides a header like the If-Modified-Since header   to provide a time against which to compare. Utilizing this saves bandwidth and reprocessing on both the server and client, as only the header data must be sent and received in comparison to   the entirety of the page being re-processed by the server, then resent using more bandwidth of the server and client.</dd>
<dt><a id="code-305" title="Use Proxy">305 Use Proxy</a> </dt>
<dd><a href="/e/305/" rel="nofollow" title="ErrorDocument 305" >ErrorDocument Use Proxy</a>  |  <a href="#status-305" rel="nofollow"  title="Sample Use Proxy">Sample 305 Use Proxy</a> <br />Many HTTP clients (such as Mozilla[4] and Internet Explorer) do not correctly handle responses with this status code, primarily for security   reasons.</dd>
<dt><a id="code-306" title="Switch Proxy">306 Switch Proxy</a> </dt>
<dd><a href="/e/306/" rel="nofollow" title="ErrorDocument 306" >ErrorDocument Switch Proxy</a>  |  <a href="#status-306" rel="nofollow"  title="Sample Switch Proxy">Sample 306 Switch Proxy</a> <br />No longer used.</dd>
<dt><a id="code-307" title="Temporary Redirect">307 Temporary Redirect</a> </dt>
<dd><a href="/e/307/" rel="nofollow" title="ErrorDocument 307" >ErrorDocument Temporary Redirect</a>  |  <a href="#status-307" rel="nofollow"  title="Sample Temporary Redirect">Sample 307 Temporary Redirect</a> <br />In this occasion, the request should be repeated with another URI, but future requests can still use the original URI. In contrast to 303,   the request method should not be changed when reissuing the original request. For instance, a POST request must be repeated using another POST request.</dd>
<dt><a id="code-400" title="Bad Request">400 Bad Request</a> </dt>
<dd><a href="/e/400/" rel="nofollow" title="ErrorDocument 400" >ErrorDocument Bad Request</a>  |  <a href="#status-400" rel="nofollow"  title="Sample Bad Request">Sample 400 Bad Request</a> <br />The request contains bad syntax or cannot be fulfilled.</dd>
<dt><a id="code-401" title="Unauthorized">401 Unauthorized</a> </dt>
<dd><a href="/e/401/" rel="nofollow" title="ErrorDocument 401" >ErrorDocument Unauthorized</a>  |  <a href="#status-401" rel="nofollow"  title="Sample Unauthorized">Sample 401 Unauthorized</a> <br />Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. The response must   include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.</dd>
<dt><a id="code-402" title="Payment Required">402 Payment Required</a> </dt>
<dd><a href="/e/402/" rel="nofollow" title="ErrorDocument 402" >ErrorDocument Payment Required</a>  |  <a href="#status-402" rel="nofollow"  title="Sample Payment Required">Sample 402 Payment Required</a> <br />The original intention was that this code might be used as part of some form of digital cash or micropayment scheme, but that has not happened,   and this code has never been used.</dd>
<dt><a id="code-403" title="Forbidden">403 Forbidden</a> </dt>
<dd><a href="/e/403/" rel="nofollow" title="ErrorDocument 403" >ErrorDocument Forbidden</a>  |  <a href="#status-403" rel="nofollow"  title="Sample Forbidden">Sample 403 Forbidden</a> <br />The request was a legal request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no   difference.</dd>
<dt><a id="code-404" title="Not Found">404 Not Found</a> </dt>
<dd><a href="/e/404/" rel="nofollow" title="ErrorDocument 404" >ErrorDocument Not Found</a>  |  <a href="#status-404" rel="nofollow"  title="Sample Not Found">Sample 404 Not Found</a> <br />The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.</dd>
<dt><a id="code-405" title="Method Not Allowed">405 Method Not Allowed</a> </dt>
<dd><a href="/e/405/" rel="nofollow" title="ErrorDocument 405" >ErrorDocument Method Not Allowed</a>  |  <a href="#status-405" rel="nofollow"  title="Sample Method Not Allowed">Sample 405 Method Not Allowed</a> <br />A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data   to be presented via POST, or using PUT on a read-only resource.</dd>
<dt><a id="code-406" title="Not Acceptable">406 Not Acceptable</a> </dt>
<dd><a href="/e/406/" rel="nofollow" title="ErrorDocument 406" >ErrorDocument Not Acceptable</a>  |  <a href="#status-406" rel="nofollow"  title="Sample Not Acceptable">Sample 406 Not Acceptable</a> <br />The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.</dd>
<dt><a id="code-407" title="Proxy Authentication Required">407 Proxy Authentication Required</a> </dt>
<dd><a href="/e/407/" rel="nofollow" title="ErrorDocument 407" >ErrorDocument Proxy Authentication Required</a>  |  <a href="#status-407" rel="nofollow"  title="Sample Proxy Authentication Required">Sample 407 Proxy Authentication Required</a> <br />Required</dd>
<dt><a id="code-408" title="Request Timeout">408 Request Timeout</a> </dt>
<dd><a href="/e/408/" rel="nofollow" title="ErrorDocument 408" >ErrorDocument Request Timeout</a>  |  <a href="#status-408" rel="nofollow"  title="Sample Request Timeout">Sample 408 Request Timeout</a> <br />The server timed out waiting for the request.</dd>
<dt><a id="code-409" title="Conflict">409 Conflict</a> </dt>
<dd><a href="/e/409/" rel="nofollow" title="ErrorDocument 409" >ErrorDocument Conflict</a>  |  <a href="#status-409" rel="nofollow"  title="Sample Conflict">Sample 409 Conflict</a> <br />Indicates that the request could not be processed because of conflict in the request, such as an edit conflict.</dd>
<dt><a id="code-410" title="Gone">410 Gone</a> </dt>
<dd><a href="/e/410/" rel="nofollow" title="ErrorDocument 410" >ErrorDocument Gone</a>  |  <a href="#status-410" rel="nofollow"  title="Sample Gone">Sample 410 Gone</a> <br />Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally   removed; however, it is not necessary to return this code and a 404 Not Found can be issued instead. Upon receiving a 410 status code, the client should not request the resource again in the   future. Clients such as search engines should remove the resource from their indexes.</dd>
<dt><a id="code-411" title="Length Required">411 Length Required</a> </dt>
<dd><a href="/e/411/" rel="nofollow" title="ErrorDocument 411" >ErrorDocument Length Required</a>  |  <a href="#status-411" rel="nofollow"  title="Sample Length Required">Sample 411 Length Required</a> <br />The request did not specify the length of its content, which is required by the requested resource.</dd>
<dt><a id="code-412" title="Precondition Failed">412 Precondition Failed</a> </dt>
<dd><a href="/e/412/" rel="nofollow" title="ErrorDocument 412" >ErrorDocument Precondition Failed</a>  |  <a href="#status-412" rel="nofollow"  title="Sample Precondition Failed">Sample 412 Precondition Failed</a> <br />The server does not meet one of the preconditions that the requester put on the request.</dd>
<dt><a id="code-413" title="Request Entity Too Large">413 Request Entity Too Large</a> </dt>
<dd><a href="/e/413/" rel="nofollow" title="ErrorDocument 413" >ErrorDocument Request Entity Too Large</a>  |  <a href="#status-413" rel="nofollow"  title="Sample Request Entity Too Large">Sample 413 Request Entity Too Large</a> <br />The request is larger than the server is willing or able to process.</dd>
<dt><a id="code-414" title="Request-URI Too Long">414 Request-URI Too Long</a> </dt>
<dd><a href="/e/414/" rel="nofollow" title="ErrorDocument 414" >ErrorDocument Request-URI Too Long</a>  |  <a href="#status-414" rel="nofollow"  title="Sample Request-URI Too Long">Sample 414 Request-URI Too Long</a> <br />The URI provided was too long for the server to process.</dd>
<dt><a id="code-415" title="Unsupported Media Type">415 Unsupported Media Type</a> </dt>
<dd><a href="/e/415/" rel="nofollow" title="ErrorDocument 415" >ErrorDocument Unsupported Media Type</a>  |  <a href="#status-415" rel="nofollow"  title="Sample Unsupported Media Type">Sample 415 Unsupported Media Type</a> <br />The request did not specify any media types that the server or resource supports. For example the client specified that an image resource   should be served as image/svg+xml, but the server cannot find a matching version of the image.</dd>
<dt><a id="code-416" title="Requested Range Not Satisfiable">416 Requested Range Not Satisfiable</a> </dt>
<dd><a href="/e/416/" rel="nofollow" title="ErrorDocument 416" >ErrorDocument Requested Range Not Satisfiable</a>  |  <a href="#status-416" rel="nofollow"  title="Sample Requested Range Not Satisfiable">Sample 416 Requested Range Not Satisfiable</a> <br />The client has asked for a portion of the file, but the server cannot supply that portion (for example, if the client asked for   a part of the file that lies beyond the end of the file).</dd>
<dt><a id="code-417" title="Expectation Failed">417 Expectation Failed</a> </dt>
<dd><a href="/e/417/" rel="nofollow" title="ErrorDocument 417" >ErrorDocument Expectation Failed</a>  |  <a href="#status-417" rel="nofollow"  title="Sample Expectation Failed">Sample 417 Expectation Failed</a> <br />The server cannot meet the requirements of the Expect request-header field.</dd>
<dt><a id="code-418" title="I'm a teapot">418 I&#8217;m a teapot</a> </dt>
<dd><a href="/e/418/" rel="nofollow" title="ErrorDocument 418" >ErrorDocument I&#8217;m a teapot</a>  |  <a href="#status-418" rel="nofollow"  title="Sample I'm a teapot">Sample 418 I&#8217;m a teapot</a> <br />The HTCPCP server is a teapot. The responding entity MAY be short and stout. Defined by the April Fools specification RFC 2324. See Hyper Text   Coffee Pot Control Protocol for more information.</dd>
<dt><a id="code-422" title="Unprocessable Entity">422 Unprocessable Entity</a> </dt>
<dd><a href="/e/422/" rel="nofollow" title="ErrorDocument 422" >ErrorDocument Unprocessable Entity</a>  |  <a href="#status-422" rel="nofollow"  title="Sample Unprocessable Entity">Sample 422 Unprocessable Entity</a> <br />(WebDAV) (RFC 4918 ) &#8211; The request was well-formed but was unable to be followed due to semantic errors.</dd>
<dt><a id="code-423" title="Locked">423 Locked</a> </dt>
<dd><a href="/e/423/" rel="nofollow" title="ErrorDocument 423" >ErrorDocument Locked</a>  |  <a href="#status-423" rel="nofollow"  title="Sample Locked">Sample 423 Locked</a> <br />(WebDAV) (RFC 4918 ) &#8211; The resource that is being accessed is locked</dd>
<dt><a id="code-424" title="Failed Dependency">424 Failed Dependency</a> </dt>
<dd><a href="/e/424/" rel="nofollow" title="ErrorDocument 424" >ErrorDocument Failed Dependency</a>  |  <a href="#status-424" rel="nofollow"  title="Sample Failed Dependency">Sample 424 Failed Dependency</a> <br />(WebDAV) (RFC 4918 ) &#8211; The request failed due to failure of a previous request (e.g. a PROPPATCH).</dd>
<dt><a id="code-425" title="Unordered Collection">425 Unordered Collection</a> </dt>
<dd><a href="/e/425/" rel="nofollow" title="ErrorDocument 425" >ErrorDocument Unordered Collection</a>  |  <a href="#status-425" rel="nofollow"  title="Sample Unordered Collection">Sample 425 Unordered Collection</a> <br />Defined in drafts of WebDav Advanced Collections, but not present in &#8220;Web Distributed Authoring and Versioning (WebDAV) Ordered Collections   Protocol&#8221; (RFC 3648).</dd>
<dt><a id="code-426" title="Upgrade Required">426 Upgrade Required</a> </dt>
<dd><a href="/e/426/" rel="nofollow" title="ErrorDocument 426" >ErrorDocument Upgrade Required</a>  |  <a href="#status-426" rel="nofollow"  title="Sample Upgrade Required">Sample 426 Upgrade Required</a> <br />(RFC 2817 ) &#8211; The client should switch to TLS/1.0.</dd>
<dt><a id="code-449" title="Retry With">449 Retry With</a> </dt>
<dd><a href="/e/449/" rel="nofollow" title="ErrorDocument 449" >ErrorDocument Retry With</a>  |  <a href="#status-449" rel="nofollow"  title="Sample Retry With">Sample 449 Retry With</a> <br />A Microsoft extension. The request should be retried after doing the appropriate action.</dd>
<dt><a id="code-500" title="Internal Server Error">500 Internal Server Error</a> </dt>
<dd><a href="/e/500/" rel="nofollow" title="ErrorDocument 500" >ErrorDocument Internal Server Error</a>  |  <a href="#status-500" rel="nofollow"  title="Sample Internal Server Error">Sample 500 Internal Server Error</a> <br />A generic error message, given when no more specific message is suitable.</dd>
<dt><a id="code-501" title="Not Implemented">501 Not Implemented</a> </dt>
<dd><a href="/e/501/" rel="nofollow" title="ErrorDocument 501" >ErrorDocument Not Implemented</a>  |  <a href="#status-501" rel="nofollow"  title="Sample Not Implemented">Sample 501 Not Implemented</a> <br />The server either does not recognise the request method, or it lacks the ability to fulfil the request.</dd>
<dt><a id="code-502" title="Bad Gateway">502 Bad Gateway</a> </dt>
<dd><a href="/e/502/" rel="nofollow" title="ErrorDocument 502" >ErrorDocument Bad Gateway</a>  |  <a href="#status-502" rel="nofollow"  title="Sample Bad Gateway">Sample 502 Bad Gateway</a> <br />The server was acting as a gateway or proxy and received an invalid response from the upstream server.</dd>
<dt><a id="code-503" title="Service Unavailable">503 Service Unavailable</a> </dt>
<dd><a href="/e/503/" rel="nofollow" title="ErrorDocument 503" >ErrorDocument Service Unavailable</a>  |  <a href="#status-503" rel="nofollow"  title="Sample Service Unavailable">Sample 503 Service Unavailable</a> <br />The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.</dd>
<dt><a id="code-504" title="Gateway Timeout">504 Gateway Timeout</a> </dt>
<dd><a href="/e/504/" rel="nofollow" title="ErrorDocument 504" >ErrorDocument Gateway Timeout</a>  |  <a href="#status-504" rel="nofollow"  title="Sample Gateway Timeout">Sample 504 Gateway Timeout</a> <br />The server was acting as a gateway or proxy and did not receive a timely request from the upstream server.</dd>
<dt><a id="code-505" title="HTTP Version Not Supported">505 HTTP Version Not Supported</a> </dt>
<dd><a href="/e/505/" rel="nofollow" title="ErrorDocument 505" >ErrorDocument HTTP Version Not Supported</a>  |  <a href="#status-505" rel="nofollow"  title="Sample HTTP Version Not Supported">Sample 505 HTTP Version Not Supported</a> <br />The server does not support the HTTP protocol version used in the request.</dd>
<dt><a id="code-506" title="Variant Also Negotiates">506 Variant Also Negotiates</a> </dt>
<dd><a href="/e/506/" rel="nofollow" title="ErrorDocument 506" >ErrorDocument Variant Also Negotiates</a>  |  <a href="#status-506" rel="nofollow"  title="Sample Variant Also Negotiates">Sample 506 Variant Also Negotiates</a> <br />(RFC 2295 ) &#8211; Transparent content negotiation for the request, results in a circular reference.</dd>
<dt><a id="code-507" title="Insufficient Storage">507 Insufficient Storage</a> </dt>
<dd><a href="/e/507/" rel="nofollow" title="ErrorDocument 507" >ErrorDocument Insufficient Storage</a>  |  <a href="#status-507" rel="nofollow"  title="Sample Insufficient Storage">Sample 507 Insufficient Storage</a> <br />(WebDAV) (RFC 4918 )</dd>
<dt><a id="code-509" title="Bandwidth Limit Exceeded">509 Bandwidth Limit Exceeded</a> </dt>
<dd><a href="/e/509/" rel="nofollow" title="ErrorDocument 509" >ErrorDocument Bandwidth Limit Exceeded</a>  |  <a href="#status-509" rel="nofollow"  title="Sample Bandwidth Limit Exceeded">Sample 509 Bandwidth Limit Exceeded</a> <br />(Apache bw/limited extension) &#8211; This status code, while used by many servers, is not specified in any RFCs.</dd>
<dt><a id="code-510" title="Not Extended">510 Not Extended</a> </dt>
<dd><a href="/e/510/" rel="nofollow" title="ErrorDocument 510" >ErrorDocument Not Extended</a>  |  <a href="#status-510" rel="nofollow"  title="Sample Not Extended">Sample 510 Not Extended</a> <br />(RFC 2774 ) &#8211; Further extensions to the request are required for the server to fulfil it.</dd>
</dl>
<h3>1xx Info / Informational</h3>
<p><code>HTTP_INFO</code> &#8211; <strong>Request received, continuing process</strong>. Indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.</p>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#status-100" title="Continue">100</a>  <a href="/e/100/" rel="nofollow" title="ErrorDocument 100" >Continue</a>  &#8211; <code>HTTP_CONTINUE</code></li>
<li> <a href="#status-101" rel="nofollow"  title="Switching Protocols">101</a>  <a href="/e/101/" rel="nofollow" title="ErrorDocument 101" >Switching Protocols</a>  &#8211; <code>HTTP_SWITCHING_PROTOCOLS</code></li>
<li> <a href="#status-102" rel="nofollow"  title="Processing">102</a>  <a href="/e/102/" rel="nofollow" title="ErrorDocument 102" >Processing</a>  &#8211; <code>HTTP_PROCESSING</code></li>
</ul>
<h3>2xx Success / OK</h3>
<p><code>HTTP_SUCCESS</code> &#8211; <strong>The action was successfully received, understood, and accepted</strong>.  Indicates that the client&#8217;s request was successfully received, understood, and accepted.</p>
<ul>
<li> <a href="#status-200" rel="nofollow"  title="OK">200</a>  <a href="/e/200/" rel="nofollow" title="ErrorDocument 200" >OK</a>  &#8211; <code>HTTP_OK</code></li>
<li> <a href="#status-201" rel="nofollow"  title="Created">201</a>  <a href="/e/201/" rel="nofollow" title="ErrorDocument 201" >Created</a>  &#8211; <code>HTTP_CREATED</code></li>
<li> <a href="#status-202" rel="nofollow"  title="Accepted">202</a>  <a href="/e/202/" rel="nofollow" title="ErrorDocument 202" >Accepted</a>  &#8211; <code>HTTP_ACCEPTED</code></li>
<li> <a href="#status-203" rel="nofollow"  title="Non-Authoritative Information">203</a>  <a href="/e/203/" rel="nofollow" title="ErrorDocument 203" >Non-Authoritative Information</a>  &#8211; <code>HTTP_NON_AUTHORITATIVE</code></li>
<li> <a href="#status-204" rel="nofollow"  title="No Content">204</a>  <a href="/e/204/" rel="nofollow" title="ErrorDocument 204" >No Content</a>  &#8211; <code>HTTP_NO_CONTENT</code></li>
<li> <a href="#status-205" rel="nofollow"  title="Reset Content">205</a>  <a href="/e/205/" rel="nofollow" title="ErrorDocument 205" >Reset Content</a>  &#8211; <code>HTTP_RESET_CONTENT</code></li>
<li> <a href="#status-206" rel="nofollow"  title="Partial Content">206</a>  <a href="/e/206/" rel="nofollow" title="ErrorDocument 206" >Partial Content</a>  &#8211; <code>HTTP_PARTIAL_CONTENT</code></li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#status-207" title="Multi-Status">207</a>  <a href="/e/207/" rel="nofollow" title="ErrorDocument 207" >Multi-Status</a>  &#8211; <code>HTTP_MULTI_STATUS</code></li>
</ul>
<h3>3xx Redirect</h3>
<p><code>HTTP_REDIRECT</code> &#8211; <strong>The client must take additional action to complete the request</strong>.  Indicates that further action needs to be taken by the user-agent in order to fulfill the request. The action required may be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A user agent should not automatically <em>redirect a request more than 5 times</em>, since such redirections usually indicate an <strong>infinite loop</strong>.</p>
<ul>
<li> <a href="#status-300" rel="nofollow"  title="Multiple Choices">300</a>  <a href="/e/300/" rel="nofollow" title="ErrorDocument 300" >Multiple Choices</a>  &#8211; <code>HTTP_MULTIPLE_CHOICES</code></li>
<li> <a href="#status-301" rel="nofollow"  title="Moved Permanently">301</a>  <a href="/e/301/" rel="nofollow" title="ErrorDocument 301" >Moved Permanently</a>  &#8211; <code>HTTP_MOVED_PERMANENTLY</code></li>
<li> <a href="#status-302" rel="nofollow"  title="Found">302</a>  <a href="/e/302/" rel="nofollow" title="ErrorDocument 302" >Found</a>  &#8211; <code>HTTP_MOVED_TEMPORARILY</code></li>
<li> <a href="#status-303" rel="nofollow"  title="See Other">303</a>  <a href="/e/303/" rel="nofollow" title="ErrorDocument 303" >See Other</a>  &#8211; <code>HTTP_SEE_OTHER</code></li>
<li> <a href="#status-304" rel="nofollow"  title="Not Modified">304</a>  <a href="/e/304/" rel="nofollow" title="ErrorDocument 304" >Not Modified</a>  &#8211; <code>HTTP_NOT_MODIFIED</code></li>
<li> <a href="#status-305" rel="nofollow"  title="Use Proxy">305</a>  <a href="/e/305/" rel="nofollow" title="ErrorDocument 305" >Use Proxy</a>  &#8211; <code>HTTP_USE_PROXY</code></li>
<li> <a href="#status-306" rel="nofollow"  title="unused">306</a>  <a href="/e/306/" rel="nofollow" title="ErrorDocument 306" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-307" rel="nofollow"  title="Temporary Redirect">307</a>  <a href="/e/307/" rel="nofollow" title="ErrorDocument 307" >Temporary Redirect</a>  &#8211; <code>HTTP_TEMPORARY_REDIRECT</code></li>
</ul>
<h3>4xx Client Error</h3>
<p><code>HTTP_CLIENT_ERROR</code> &#8211; <strong>The request contains bad syntax or cannot be fulfilled</strong>.  Indicates case where client seems to have erred. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition.</p>
<ul>
<li> <a href="#status-400" rel="nofollow"  title="Bad Request">400</a>  <a href="/e/400/" rel="nofollow" title="ErrorDocument 400" >Bad Request</a>  &#8211; <code>HTTP_BAD_REQUEST</code></li>
<li> <a href="#status-401" rel="nofollow"  title="Authorization Required">401</a>  <a href="/e/401/" rel="nofollow" title="ErrorDocument 401" >Authorization Required</a>  &#8211; <code>HTTP_UNAUTHORIZED</code></li>
<li> <a href="#status-402" rel="nofollow"  title="Payment Required">402</a>  <a href="/e/402/" rel="nofollow" title="ErrorDocument 402" >Payment Required</a>  &#8211; <code>HTTP_PAYMENT_REQUIRED</code></li>
<li> <a href="#status-403" rel="nofollow"  title="Forbidden">403</a>  <a href="/e/403/" rel="nofollow" title="ErrorDocument 403" >Forbidden</a>  &#8211; <code>HTTP_FORBIDDEN</code></li>
<li> <a href="#status-404" rel="nofollow"  title="Not Found">404</a>  <a href="/e/404/" rel="nofollow" title="ErrorDocument 404" >Not Found</a>  &#8211; <code>HTTP_NOT_FOUND</code></li>
<li> <a href="#status-405" rel="nofollow"  title="Method Not Allowed">405</a>  <a href="/e/405/" rel="nofollow" title="ErrorDocument 405" >Method Not Allowed</a>  &#8211; <code>HTTP_METHOD_NOT_ALLOWED</code></li>
<li> <a href="#status-406" rel="nofollow"  title="Not Acceptable">406</a>  <a href="/e/406/" rel="nofollow" title="ErrorDocument 406" >Not Acceptable</a>  &#8211; <code>HTTP_NOT_ACCEPTABLE</code></li>
<li> <a href="#status-407" rel="nofollow"  title="Proxy Authentication Required">407</a>  <a href="/e/407/" rel="nofollow" title="ErrorDocument 407" >Proxy Authentication Required</a>  &#8211; <code>HTTP_PROXY_AUTHENTICATION_REQUIRED</code></li>
<li> <a href="#status-408" rel="nofollow"  title="Request Time-out">408</a>  <a href="/e/408/" rel="nofollow" title="ErrorDocument 408" >Request Time-out</a>  &#8211; <code>HTTP_REQUEST_TIME_OUT</code></li>
<li> <a href="#status-409" rel="nofollow"  title="Conflict">409</a>  <a href="/e/409/" rel="nofollow" title="ErrorDocument 409" >Conflict</a>  &#8211; <code>HTTP_CONFLICT</code></li>
<li> <a href="#status-410" rel="nofollow"  title="Gone">410</a>  <a href="/e/410/" rel="nofollow" title="ErrorDocument 410" >Gone</a>  &#8211; <code>HTTP_GONE</code></li>
<li> <a href="#status-411" rel="nofollow"  title="Length Required">411</a>  <a href="/e/411/" rel="nofollow" title="ErrorDocument 411" >Length Required</a>  &#8211; <code>HTTP_LENGTH_REQUIRED</code></li>
<li> <a href="#status-412" rel="nofollow"  title="Precondition Failed">412</a>  <a href="/e/412/" rel="nofollow" title="ErrorDocument 412" >Precondition Failed</a>  &#8211; <code>HTTP_PRECONDITION_FAILED</code></li>
<li> <a href="#status-413" rel="nofollow"  title="Request Entity Too Large">413</a>  <a href="/e/413/" rel="nofollow" title="ErrorDocument 413" >Request Entity Too Large</a>  &#8211; <code>HTTP_REQUEST_ENTITY_TOO_LARGE</code></li>
<li> <a href="#status-414" rel="nofollow"  title="Request-URI Too Large">414</a>  <a href="/e/414/" rel="nofollow" title="ErrorDocument 414" >Request-URI Too Large</a>  &#8211; <code>HTTP_REQUEST_URI_TOO_LARGE</code></li>
<li> <a href="#status-415" rel="nofollow"  title="Unsupported Media Type">415</a>  <a href="/e/415/" rel="nofollow" title="ErrorDocument 415" >Unsupported Media Type</a>  &#8211; <code>HTTP_UNSUPPORTED_MEDIA_TYPE</code></li>
<li> <a href="#status-416" rel="nofollow"  title="Requested Range Not Satisfiable">416</a>  <a href="/e/416/" rel="nofollow" title="ErrorDocument 416" >Requested Range Not Satisfiable</a>  &#8211; <code>HTTP_RANGE_NOT_SATISFIABLE</code></li>
<li> <a href="#status-417" rel="nofollow"  title="Expectation Failed">417</a>  <a href="/e/417/" rel="nofollow" title="ErrorDocument 417" >Expectation Failed</a>  &#8211; <code>HTTP_EXPECTATION_FAILED</code></li>
<li> <a href="#status-418" rel="nofollow"  title="Im a teapot">418</a>  <a href="/e/418/" rel="nofollow" title="ErrorDocument 418" >I&#8217;m a teapot</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-419" rel="nofollow"  title="unused">419</a>  <a href="/e/419/" rel="nofollow" title="ErrorDocument 419" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-420" rel="nofollow"  title="unused">420</a>  <a href="/e/420/" rel="nofollow" title="ErrorDocument 420" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-421" rel="nofollow"  title="unused">421</a>  <a href="/e/421/" rel="nofollow" title="ErrorDocument 421" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-422" rel="nofollow"  title="Unprocessable Entity">422</a>  <a href="/e/422/" rel="nofollow" title="ErrorDocument 422" >Unprocessable Entity</a>  &#8211; <code>HTTP_UNPROCESSABLE_ENTITY</code></li>
<li> <a href="#status-423" rel="nofollow"  title="Locked">423</a>  <a href="/e/423/" rel="nofollow" title="ErrorDocument 423" >Locked</a>  &#8211; <code>HTTP_LOCKED</code></li>
<li> <a href="#status-424" rel="nofollow"  title="Failed Dependency">424</a>  <a href="/e/424/" rel="nofollow" title="ErrorDocument 424" >Failed Dependency</a>  &#8211; <code>HTTP_FAILED_DEPENDENCY</code></li>
<li> <a href="#status-425" rel="nofollow"  title="No code">425</a>  <a href="/e/425/" rel="nofollow" title="ErrorDocument 425" >No code</a>  &#8211; <code>HTTP_NO_CODE</code></li>
<li> <a href="#status-426" rel="nofollow"  title="Upgrade Required">426</a>  <a href="/e/426/" rel="nofollow" title="ErrorDocument 426" >Upgrade Required</a>  &#8211; <code>HTTP_UPGRADE_REQUIRED</code></li>
</ul>
<h3>5xx Server Error</h3>
<p><code>HTTP_SERVER_ERROR</code> &#8211; <strong>The server failed to fulfill an apparently valid request</strong>.  Indicate cases in which the server is aware that it has erred or is incapable of performing the request. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents should display any included entity to the user. These response codes are applicable to any request method.</p>
<ul>
<li> <a href="#status-500" rel="nofollow"  title="Internal Server Error">500</a>  <a href="/e/500/" rel="nofollow" title="ErrorDocument 500" >Internal Server Error</a>  &#8211; <code>HTTP_INTERNAL_SERVER_ERROR</code></li>
<li> <a href="#status-501" rel="nofollow"  title="Method Not Implemented">501</a>  <a href="/e/501/" rel="nofollow" title="ErrorDocument 501" >Method Not Implemented</a>  &#8211; <code>HTTP_NOT_IMPLEMENTED</code></li>
<li> <a href="#status-502" rel="nofollow"  title="Bad Gateway">502</a>  <a href="/e/502/" rel="nofollow" title="ErrorDocument 502" >Bad Gateway</a>  &#8211; <code>HTTP_BAD_GATEWAY</code></li>
<li> <a href="#status-503" rel="nofollow"  title="Service Temporarily Unavailable">503</a>  <a href="/e/503/" rel="nofollow" title="ErrorDocument 503" >Service Temporarily Unavailable</a>  &#8211; <code>HTTP_SERVICE_UNAVAILABLE</code></li>
<li> <a href="#status-504" rel="nofollow"  title="Gateway Time-out">504</a>  <a href="/e/504/" rel="nofollow" title="ErrorDocument 504" >Gateway Time-out</a>  &#8211; <code>HTTP_GATEWAY_TIME_OUT</code></li>
<li> <a href="#status-505" rel="nofollow"  title="HTTP Version Not Supported">505</a>  <a href="/e/505/" rel="nofollow" title="ErrorDocument 505" >HTTP Version Not Supported</a>  &#8211; <code>HTTP_VERSION_NOT_SUPPORTED</code></li>
<li> <a href="#status-506" rel="nofollow"  title="Variant Also Negotiates">506</a>  <a href="/e/506/" rel="nofollow" title="ErrorDocument 506" >Variant Also Negotiates</a>  &#8211; <code>HTTP_VARIANT_ALSO_VARIES</code></li>
<li> <a href="#status-507" rel="nofollow"  title="Insufficient Storage">507</a>  <a href="/e/507/" rel="nofollow" title="ErrorDocument 507" >Insufficient Storage</a>  &#8211; <code>HTTP_INSUFFICIENT_STORAGE</code></li>
<li> <a href="#status-508" rel="nofollow"  title="unused">508</a>  <a href="/e/508/" rel="nofollow" title="ErrorDocument 508" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-509" rel="nofollow"  title="unused">509</a>  <a href="/e/509/" rel="nofollow" title="ErrorDocument 509" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-510" rel="nofollow"  title="Not Extended">510</a>  <a href="/e/510/" rel="nofollow" title="ErrorDocument 510" >Not Extended</a>  &#8211; <code>HTTP_NOT_EXTENDED</code></li>
</ul>
<hr />
<h2> <a href="#quick-start" rel="nofollow"  name="quick-start" id="quick-start">Quick Start to triggering ErrorDocuments for each Status Code</a> </h2>
<p>Let start with a quick and easy example.  Add the following Redirect rules to your htaccess file, then open your browser and goto each url like <code>yoursite.com/e/400</code>. <em>Don&#8217;t create an /e/ directory or any files.</em></p>
<pre>Redirect 400 /e/400
Redirect 503 /e/503
Redirect 405 /e/405</pre>
<p> <a href="http://uploads.askapache.com/2007/03/error-400s.png" rel="nofollow"  title="Apache ErrorDocument Results" rel="lb"><img src="http://uploads.askapache.com/2007/03/error-400s.thumbnail.png" alt="Apache ErrorDocument Results" title="error 400s.thumbnail apache" /></a> <br /> <a href="http://uploads.askapache.com/2007/03/error-503.png" rel="nofollow"  title="error 503" rel="lb"><img src="http://uploads.askapache.com/2007/03/error-503.thumbnail.png" alt="error 503" title="error 503.thumbnail apache" /></a> </p>
<h2> <a href="#automating-the-process" rel="nofollow"  name="automating-the-process" id="automating-the-process">Automate the ErrorDocument Triggering</a> </h2>
<h3> <a href="#redirect-code-in-htaccess" rel="nofollow"  name="redirect-code-in-htaccess" id="redirect-code-in-htaccess">The htaccess Redirects</a> </h3>
<p>When a Status code is encountered, Apache outputs the Header and the ErrorDocument for that error code.  So you can view any Header and the default ErrorDocument, by causing that numerical error code, which is caused by the Status Code.</p>
<p>For instance, if you request a file that doesn&#8217;t exist, a <strong>404 Not Found</strong> Header is issued and the corresponding ErrorDocument is served with the <strong>404 Not Found</strong> Header.</p>
<pre>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 300 /e/300 http://www.askapache.com/?s=300
Redirect 301 /e/301 http://www.askapache.com/?s=301
Redirect 302 /e/302 http://www.askapache.com/?s=302
Redirect 303 /e/303 http://www.askapache.com/?s=303
Redirect 304 /e/304 http://www.askapache.com/?s=304
Redirect 305 /e/305 http://www.askapache.com/?s=305
Redirect 306 /e/306 http://www.askapache.com/?s=306
Redirect 307 /e/307 http://www.askapache.com/?s=307
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 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</pre>
<h3> <a href="#php-header-grabber-script" rel="nofollow"  name="php-header-grabber-script" id="php-header-grabber-script">PHP script that gets and outputs the Headers/Content</a> </h3>
<p>Now all I have to do is add 57 Redirect Directives to my htaccess, and then request each of them 1 at a time from my browser to see the result, and use a packet sniffing program like  <a href="http://wireshark.askapache.com" rel="nofollow" >WireShark</a>  to see the Headers.  Uh, scratch that, that would take way too long!</p>
<p>Instead I hacked up a simple php script using  <a href="http://www.askapache.com/phpbb/sending-post-form-data-with-php-curl.html">cURL</a>  to automate sending GET Requests to each of the 57 Redirect URL-paths. A side benefit of using the php script is that it performs all 57 Requests concurrently and saves each Requests returned headers and content to an output buffer.  After all 57 have been queried, the output buffer is flushed to the browser.</p>
<pre>&lt;?php
$SITENAME=&#039;http://www.askapache.com&#039;;
&nbsp;
$CODES = array(array(&#039;100&#039;,&#039;101&#039;,&#039;102&#039;),
array(&#039;200&#039;,&#039;201&#039;,&#039;202&#039;,&#039;203&#039;,&#039;204&#039;,&#039;205&#039;,&#039;206&#039;,&#039;207&#039;),
array(&#039;300&#039;,&#039;301&#039;,&#039;302&#039;,&#039;303&#039;,&#039;304&#039;,&#039;305&#039;,&#039;306&#039;,&#039;307&#039;),
array(&#039;400&#039;,&#039;401&#039;,&#039;402&#039;,&#039;403&#039;,&#039;404&#039;,&#039;405&#039;,&#039;406&#039;,&#039;407&#039;,&#039;408&#039;,&#039;409&#039;,&#039;410&#039;,&#039;411&#039;,&#039;412&#039;,&#039;413&#039;,
&#039;414&#039;,&#039;415&#039;,&#039;416&#039;,&#039;417&#039;,&#039;418&#039;,&#039;419&#039;,&#039;420&#039;,&#039;421&#039;,&#039;422&#039;,&#039;423&#039;,&#039;424&#039;,&#039;425&#039;,&#039;426&#039;),
array(&#039;500&#039;,&#039;501&#039;,&#039;502&#039;,&#039;503&#039;,&#039;504&#039;,&#039;505&#039;,&#039;506&#039;,&#039;507&#039;,&#039;508&#039;,&#039;509&#039;,&#039;510&#039;));
&nbsp;
$TMPSAVETO=&#039;/tmp/&#039;.time().&#039;.txt&#039;;
&nbsp;
# if file exists then delete it
if(is_file($TMPSAVETO))unlink($TMPSAVETO);
&nbsp;
foreach($CODES as $keyd =&gt; $res)
{
foreach($res as $key)
{
$ch = curl_init(&quot;$SITENAME/e/$key&quot;);
$fp = fopen ($TMPSAVETO, &quot;a&quot;);
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt ($ch, CURLOPT_HEADER ,1);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
}
}
$OUT=&#039;&#039;;
ob_start();
header (&quot;Content-Type: text/plain;&quot;);
readfile($TMPSAVETO);
$OUT=ob_get_clean();
echo $OUT;
unlink($TMPSAVETO);
exit;
?&gt;</pre>
<h2> <a href="#headers-returned-content" rel="nofollow"  id="headers-returned-content">Headers and Content Returned</a> </h2>
<h3> <a href="#status-100" rel="nofollow"  name="status-100" id="status-100">100 Continue</a> </h3>
<pre>HTTP/1.1 100 Continue
&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-101" rel="nofollow"  name="status-101" id="status-101">101 Switching Protocols</a> </h3>
<pre>HTTP/1.1 101 Switching Protocols&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-102" rel="nofollow"  name="status-102" id="status-102">102 Processing</a> </h3>
<pre>HTTP/1.1 102 Processing
X-Pad: avoid browser bug&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-200" rel="nofollow"  name="status-200" id="status-200">200 OK</a> </h3>
<pre>HTTP/1.1 200 OK
&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-201" rel="nofollow"  name="status-201" id="status-201">201 Created</a> </h3>
<pre>HTTP/1.1 201 Created
&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-202" rel="nofollow"  name="status-202" id="status-202">202 Accepted</a> </h3>
<pre>HTTP/1.1 202 Accepted
&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-203" rel="nofollow"  name="status-203" id="status-203">203 Non-Authoritative Information</a> </h3>
<pre>HTTP/1.1 203 Non-Authoritative Information
&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-204" rel="nofollow"  name="status-204" id="status-204">204 No Content</a> </h3>
<pre>HTTP/1.1 204 No Content
Content-Type: text/plain; charset=UTF-8
&nbsp;</pre>
<h3> <a href="#status-205" rel="nofollow"  name="status-205" id="status-205">205 Reset Content</a> </h3>
<pre>HTTP/1.1 205 Reset Content&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-206" rel="nofollow"  name="status-206" id="status-206">206 Partial Content</a> </h3>
<pre>HTTP/1.1 206 Partial Content&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-207" rel="nofollow"  name="status-207" id="status-207">207 Multi-Status</a> </h3>
<pre>HTTP/1.1 207 Multi-Status
X-Pad: avoid browser bug&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-300" rel="nofollow"  name="status-300" id="status-300">300 Multiple Choices</a> </h3>
<pre>HTTP/1.1 300 Multiple Choices
Location: http://www.askapache.com/?s=300&lt;html&gt;
&lt;head&gt;
&lt;title&gt;300 Multiple Choices&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Multiple Choices&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-301" rel="nofollow"  name="status-301" id="status-301">301 Moved Permanently</a> </h3>
<pre>HTTP/1.1 301 Moved Permanently
Location: http://www.askapache.com/?s=301&lt;html&gt;
&lt;head&gt;
&lt;title&gt;301 Moved Permanently&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Moved Permanently&lt;/h1&gt;
&lt;p&gt;The document has moved  &lt;a href=&quot;http://www.askapache.com/?s=301&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-302" rel="nofollow"  name="status-302" id="status-302">302 Found</a> </h3>
<pre>HTTP/1.1 302 Found
Location: http://www.askapache.com/?s=302&lt;html&gt;
&lt;head&gt;
&lt;title&gt;302 Found&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Found&lt;/h1&gt;
&lt;p&gt;The document has moved  &lt;a href=&quot;http://www.askapache.com/?s=302&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-303" rel="nofollow"  name="status-303" id="status-303">303 See Other</a> </h3>
<pre>HTTP/1.1 303 See Other
Location: http://www.askapache.com/?s=303&lt;html&gt;
&lt;head&gt;
&lt;title&gt;303 See Other&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;See Other&lt;/h1&gt;
&lt;p&gt;The answer to your request is located  &lt;a href=&quot;http://www.askapache.com/?s=303&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-304" rel="nofollow"  name="status-304" id="status-304">304 Not Modified</a> </h3>
<pre>HTTP/1.1 304 Not Modified</pre>
<h3> <a href="#status-305" rel="nofollow"  name="status-305" id="status-305">305 Use Proxy</a> </h3>
<pre>HTTP/1.1 305 Use Proxy
Location: http://www.askapache.com/?s=305&lt;html&gt;
&lt;head&gt;
&lt;title&gt;305 Use Proxy&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Use Proxy&lt;/h1&gt;
&lt;p&gt;This resource is only accessible through the proxy
    http://www.askapache.com/?s=305&lt;br /&gt;You will need to configure your client to use that proxy.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-306" rel="nofollow"  name="status-306" id="status-306">306 unused</a> </h3>
<pre>HTTP/1.1 306 unused
Location: http://www.askapache.com/?s=306&lt;html&gt;
&lt;head&gt;
&lt;title&gt;306 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-307" rel="nofollow"  name="status-307" id="status-307">307 Temporary Redirect</a> </h3>
<pre>HTTP/1.1 307 Temporary Redirect
Location: http://www.askapache.com/?s=307&lt;html&gt;
&lt;head&gt;
&lt;title&gt;307 Temporary Redirect&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Temporary Redirect&lt;/h1&gt;
&lt;p&gt;The document has moved  &lt;a href=&quot;http://www.askapache.com/?s=307&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-400" rel="nofollow"  name="status-400" id="status-400">400 Bad Request</a> </h3>
<pre>HTTP/1.1 400 Bad Request
Connection: close&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;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-401" rel="nofollow"  name="status-401" id="status-401">401 Authorization Required</a> </h3>
<pre>HTTP/1.1 401 Authorization Required&lt;html&gt;
&lt;head&gt;
&lt;title&gt;401 Authorization Required&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Authorization 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;p&gt;Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-402" rel="nofollow"  name="status-402" id="status-402">402 Payment Required</a> </h3>
<pre>HTTP/1.1 402 Payment Required&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-403" rel="nofollow"  name="status-403" id="status-403">403 Forbidden</a> </h3>
<pre>HTTP/1.1 403 Forbidden&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;p&gt;Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-404" rel="nofollow"  name="status-404" id="status-404">404 Not Found</a> </h3>
<pre>HTTP/1.1 404 Not Found&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>
<p class="anote"><span>NOTE:</span><br />You will most definately want to check out and use the <a href="http://www.askapache.com/seo/404-google-wordpress-plugin.html" title="404 Error Page WordPress Plugin">Google 404 Error Page</a> if you run WordPress.</p>
<h3> <a href="#status-405" rel="nofollow"  name="status-405" id="status-405">405 Method Not Allowed</a> </h3>
<pre>HTTP/1.1 405 Method Not Allowed
Allow: TRACE
&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>
<h3> <a href="#status-406" rel="nofollow"  name="status-406" id="status-406">406 Not Acceptable</a> </h3>
<pre>HTTP/1.1 406 Not Acceptable
&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>
<h3> <a href="#status-407" rel="nofollow"  name="status-407" id="status-407">407 Proxy Authentication Required</a> </h3>
<pre>HTTP/1.1 407 Proxy Authentication Required&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>
<h3> <a href="#status-408" rel="nofollow"  name="status-408" id="status-408">408 Request Time-out</a> </h3>
<pre>HTTP/1.1 408 Request Time-out
Connection: close
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;408 Request Time-out&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Request Time-out&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>
<h3> <a href="#status-409" rel="nofollow"  name="status-409" id="status-409">409 Conflict</a> </h3>
<pre>HTTP/1.1 409 Conflict
&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;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-410" rel="nofollow"  name="status-410" id="status-410">410 Gone</a> </h3>
<pre>HTTP/1.1 410 Gone
&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>
<h3> <a href="#status-411" rel="nofollow"  name="status-411" id="status-411">411 Length Required</a> </h3>
<pre>HTTP/1.1 411 Length Required
Connection: close
&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;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-412" rel="nofollow"  name="status-412" id="status-412">412 Precondition Failed</a> </h3>
<pre>HTTP/1.1 412 Precondition Failed
&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>
<h3> <a href="#status-413" rel="nofollow"  name="status-413" id="status-413">413 Request Entity Too Large</a> </h3>
<pre>HTTP/1.1 413 Request Entity Too Large
Connection: close&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>
<h3> <a href="#status-414" rel="nofollow"  name="status-414" id="status-414">414 Request-URI Too Large</a> </h3>
<pre>HTTP/1.1 414 Request-URI Too Large
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;414 Request-URI Too Large&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Request-URI Too Large&lt;/h1&gt;
&lt;p&gt;The requested URL&#039;s length exceeds the capacity
    limit for this server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-415" rel="nofollow"  name="status-415" id="status-415">415 Unsupported Media Type</a> </h3>
<pre>HTTP/1.1 415 Unsupported Media Type&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>
<h3> <a href="#status-416" rel="nofollow"  name="status-416" id="status-416">416 Requested Range Not Satisfiable</a> </h3>
<pre>HTTP/1.1 416 Requested Range Not Satisfiable</pre>
<h3> <a href="#status-417" rel="nofollow"  name="status-417" id="status-417">417 Expectation Failed</a> </h3>
<pre>HTTP/1.1 417 Expectation Failed&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;The expectation given in the Expect request-header
    field could not be met by this server.&lt;/p&gt;
&lt;p&gt;The client sent&lt;pre&gt;
    Expect: &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-418" rel="nofollow"  name="status-418" id="status-418">418 I&#8217;m a teapot</a> </h3>
<pre>HTTP/1.1 418 I&#039;m a teapot&lt;html&gt;
&lt;head&gt;
&lt;title&gt;418 I&#039;m a teapot&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;I&#039;m a teapot&lt;/h1&gt;
&lt;p&gt;Unfortunately this coffee machine is out of coffee.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-419" rel="nofollow"  name="status-419" id="status-419">419 unused</a> </h3>
<pre>HTTP/1.1 419 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;419 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-420" rel="nofollow"  name="status-420" id="status-420">420 unused</a> </h3>
<pre>HTTP/1.1 420 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;420 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-421" rel="nofollow"  name="status-421" id="status-421">421 unused</a> </h3>
<pre>HTTP/1.1 421 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;421 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-422" rel="nofollow"  name="status-422" id="status-422">422 Unprocessable Entity</a> </h3>
<pre>HTTP/1.1 422 Unprocessable Entity&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>
<h3> <a href="#status-423" rel="nofollow"  name="status-423" id="status-423">423 Locked</a> </h3>
<pre>HTTP/1.1 423 Locked&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>
<h3> <a href="#status-424" rel="nofollow"  name="status-424" id="status-424">424 Failed Dependency</a> </h3>
<pre>HTTP/1.1 424 Failed Dependency&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>
<h3> <a href="#status-425" rel="nofollow"  name="status-425" id="status-425">425 No code</a> </h3>
<pre>HTTP/1.1 425 No code&lt;html&gt;
&lt;head&gt;
&lt;title&gt;425 No code&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;No code&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-426" rel="nofollow"  name="status-426" id="status-426">426 Upgrade Required</a> </h3>
<pre>HTTP/1.1 426 Upgrade Required&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;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-500" rel="nofollow"  name="status-500" id="status-500">500 Internal Server Error</a> </h3>
<pre>HTTP/1.1 500 Internal Server Error
Connection: close&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 misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;p&gt;Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-501" rel="nofollow"  name="status-501" id="status-501">501 Method Not Implemented</a> </h3>
<pre>HTTP/1.1 501 Method Not Implemented
Allow: TRACE
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;501 Method Not Implemented&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Method Not Implemented&lt;/h1&gt;
&lt;p&gt;GET to /e/501 not supported.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-502" rel="nofollow"  name="status-502" id="status-502">502 Bad Gateway</a> </h3>
<pre>HTTP/1.1 502 Bad Gateway
X-Pad: avoid browser bug&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;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-503" rel="nofollow"  name="status-503" id="status-503">503 Service Temporarily Unavailable</a> </h3>
<pre>HTTP/1.1 503 Service Temporarily Unavailable
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;503 Service Temporarily Unavailable&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Service Temporarily 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>
<h3> <a href="#status-504" rel="nofollow"  name="status-504" id="status-504">504 Gateway Time-out</a> </h3>
<pre>HTTP/1.1 504 Gateway Time-out&lt;html&gt;
&lt;head&gt;
&lt;title&gt;504 Gateway Time-out&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Gateway Time-out&lt;/h1&gt;
&lt;p&gt;The proxy server did not receive a timely response
    from the upstream server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-505" rel="nofollow"  name="status-505" id="status-505">505 HTTP Version Not Supported</a> </h3>
<pre>HTTP/1.1 505 HTTP Version Not Supported&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 misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-506" rel="nofollow"  name="status-506" id="status-506">506 Variant Also Negotiates</a> </h3>
<pre>HTTP/1.1 506 Variant Also Negotiates&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>
<h3> <a href="#status-507" rel="nofollow"  name="status-507" id="status-507">507 Insufficient Storage</a> </h3>
<pre>HTTP/1.1 507 Insufficient Storage&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>
<h3> <a href="#status-508" rel="nofollow"  name="status-508" id="status-508">508 unused</a> </h3>
<pre>HTTP/1.1 508 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;508 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-509" rel="nofollow"  name="status-509" id="status-509">509 unused</a> </h3>
<pre>HTTP/1.1 509 unused
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;509 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the 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>
<h3> <a href="#status-510" rel="nofollow"  name="status-510" id="status-510">510 Not Extended</a> </h3>
<pre>HTTP/1.1 510 Not Extended
X-Pad: avoid browser bug
&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>
<h2> <a href="#apache-source-code" rel="nofollow"  name="apache-source-code" id="apache-source-code">Apache Source Code</a> </h2>
<h3> <a href="#httpdh-h" rel="nofollow"  name="httpdh-h" id="httpdh-h">httpd.h</a> </h3>
<p>From <a href="http://uploads.askapache.com/2007/02/httpd.h" rel="nofollow"  title="httpd.h Apache">httpd.h</a> </p>
<pre>/**
* The size of the static array in http_protocol.c for storing
* all of the potential response status-lines (a sparse table).
* A future version should dynamically generate the apr_table_t at startup.
*/
#define RESPONSE_CODES 57
#define HTTP_CONTINUE            100
#define HTTP_SWITCHING_PROTOCOLS       101
#define HTTP_PROCESSING          102
#define HTTP_OK              200
#define HTTP_CREATED             201
#define HTTP_ACCEPTED            202
#define HTTP_NON_AUTHORITATIVE       203
#define HTTP_NO_CONTENT          204
#define HTTP_RESET_CONTENT         205
#define HTTP_PARTIAL_CONTENT         206
#define HTTP_MULTI_STATUS          207
#define HTTP_MULTIPLE_CHOICES        300
#define HTTP_MOVED_PERMANENTLY       301
&nbsp;
#define HTTP_MOVED_TEMPORARILY       302
#define HTTP_SEE_OTHER           303
#define HTTP_NOT_MODIFIED          304
#define HTTP_USE_PROXY           305
#define HTTP_TEMPORARY_REDIRECT      307
#define HTTP_BAD_REQUEST           400
#define HTTP_UNAUTHORIZED          401
#define HTTP_PAYMENT_REQUIRED        402
#define HTTP_FORBIDDEN           403
#define HTTP_NOT_FOUND           404
#define HTTP_METHOD_NOT_ALLOWED      405
#define HTTP_NOT_ACCEPTABLE        406
#define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
#define HTTP_REQUEST_TIME_OUT        408
#define HTTP_CONFLICT            409
#define HTTP_GONE              410
#define HTTP_LENGTH_REQUIRED         411
#define HTTP_PRECONDITION_FAILED       412
#define HTTP_REQUEST_ENTITY_TOO_LARGE    413
#define HTTP_REQUEST_URI_TOO_LARGE     414
#define HTTP_UNSUPPORTED_MEDIA_TYPE    415
#define HTTP_RANGE_NOT_SATISFIABLE     416
#define HTTP_EXPECTATION_FAILED      417
#define HTTP_UNPROCESSABLE_ENTITY      422
#define HTTP_LOCKED            423
#define HTTP_FAILED_DEPENDENCY       424
#define HTTP_UPGRADE_REQUIRED        426
#define HTTP_INTERNAL_SERVER_ERROR     500
#define HTTP_NOT_IMPLEMENTED         501
#define HTTP_BAD_GATEWAY           502
#define HTTP_SERVICE_UNAVAILABLE       503
#define HTTP_GATEWAY_TIME_OUT        504
#define HTTP_VERSION_NOT_SUPPORTED     505
#define HTTP_VARIANT_ALSO_VARIES       506
#define HTTP_INSUFFICIENT_STORAGE      507
#define HTTP_NOT_EXTENDED          510
&nbsp;
/** is the status code informational */
#define ap_is_HTTP_INFO(x)     (((x) &gt;= 100)&amp;&amp;((x) &lt; 200))
/** is the status code OK ?*/
#define ap_is_HTTP_SUCCESS(x)    (((x) &gt;= 200)&amp;&amp;((x) &lt; 300))
/** is the status code a redirect */
#define ap_is_HTTP_REDIRECT(x)   (((x) &gt;= 300)&amp;&amp;((x) &lt; 400))
/** is the status code a error (client or server) */
#define ap_is_HTTP_ERROR(x)    (((x) &gt;= 400)&amp;&amp;((x) &lt; 600))
/** is the status code a client error  */
#define ap_is_HTTP_CLIENT_ERROR(x) (((x) &gt;= 400)&amp;&amp;((x) &lt; 500))
/** is the status code a server error  */
#define ap_is_HTTP_SERVER_ERROR(x) (((x) &gt;= 500)&amp;&amp;((x) &lt; 600))
/** is the status code a (potentially) valid response code?  */
#define ap_is_HTTP_VALID_RESPONSE(x) (((x) &gt;= 100)&amp;&amp;((x) &lt; 600))
&nbsp;
/** should the status code drop the connection */
#define ap_status_drops_connection(x) \
(((x) == HTTP_BAD_REQUEST)       || \
((x) == HTTP_REQUEST_TIME_OUT)    || \
((x) == HTTP_LENGTH_REQUIRED)     || \
((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
((x) == HTTP_INTERNAL_SERVER_ERROR) || \
((x) == HTTP_SERVICE_UNAVAILABLE) || \
((x) == HTTP_NOT_IMPLEMENTED))</pre>
<h4>HTTP_INFO</h4>
<p><strong>Is the status code (x) informational?</strong></p>
<pre>x &gt;= 100 &amp;&amp; x &lt; 200</pre>
<h4>HTTP_SUCCESS</h4>
<p><strong>Is the status code (x) OK?</strong></p>
<pre>x &gt;= 200 &amp;&amp; x &lt; 300</pre>
<h4>HTTP_REDIRECT</h4>
<p><strong>Is the status code (x) a redirect?</strong></p>
<pre>x &gt;= 300 &amp;&amp; x &lt; 400</pre>
<h4>HTTP_ERROR</h4>
<p><strong>Is the status code (x) a error (client or server)?</strong></p>
<pre>x &gt;= 400 &amp;&amp; x &lt; 600</pre>
<h4>HTTP_CLIENT_ERROR</h4>
<p><strong>Is the status code (x) a client error?</strong></p>
<pre>x &gt;= 400 &amp;&amp; x &lt; 500</pre>
<h4>HTTP_SERVER_ERROR</h4>
<p><strong>Is the status code (x) a server error?</strong></p>
<pre>x &gt;= 500 &amp;&amp; x &lt; 600</pre>
<h4>HTTP_VALID_RESPONSE</h4>
<p><strong>Is the status code (x) a (potentially) valid response code?</strong></p>
<pre>x &gt;= 100 &amp;&amp; x &lt; 600</pre>
<h3> <a href="#http_protocol-c" rel="nofollow"  name="http_protocol-c" id="http_protocol-c">http_protocol.c</a> </h3>
<p>From <a href="http://uploads.askapache.com/2007/02/http_protocol.c" rel="nofollow"  title="http_protocol.c">http_protocol.c</a> </p>
<pre>static const char * status_lines[RESPONSE_CODES] =
static const char * const status_lines[RESPONSE_CODES] =
&quot;100 Continue&quot;,
&quot;101 Switching Protocols&quot;,
&quot;102 Processing&quot;,
&quot;200 OK&quot;,
&quot;201 Created&quot;,
&quot;202 Accepted&quot;,
&quot;203 Non-Authoritative Information&quot;,
&quot;204 No Content&quot;,
&quot;205 Reset Content&quot;,
&quot;206 Partial Content&quot;,
&quot;207 Multi-Status&quot;,
&quot;300 Multiple Choices&quot;,
&quot;301 Moved Permanently&quot;,
&quot;302 Found&quot;,
&quot;303 See Other&quot;,
&quot;304 Not Modified&quot;,
&quot;305 Use Proxy&quot;,
&quot;306 unused&quot;,
&quot;307 Temporary Redirect&quot;,
&quot;400 Bad Request&quot;,
&quot;401 Authorization Required&quot;,
&quot;402 Payment Required&quot;,
&quot;403 Forbidden&quot;,
&quot;404 Not Found&quot;,
&quot;405 Method Not Allowed&quot;,
&quot;406 Not Acceptable&quot;,
&quot;407 Proxy Authentication Required&quot;,
&quot;408 Request Time-out&quot;,
&quot;409 Conflict&quot;,
&quot;410 Gone&quot;,
&quot;411 Length Required&quot;,
&quot;412 Precondition Failed&quot;,
&quot;413 Request Entity Too Large&quot;,
&quot;414 Request-URI Too Large&quot;,
&quot;415 Unsupported Media Type&quot;,
&quot;416 Requested Range Not Satisfiable&quot;,
&quot;417 Expectation Failed&quot;,
&quot;418 unused&quot;,
&quot;419 unused&quot;,
&quot;420 unused&quot;,
&quot;421 unused&quot;,
&quot;422 Unprocessable Entity&quot;,
&quot;423 Locked&quot;,
&quot;424 Failed Dependency&quot;,
&quot;425 No code&quot;,
&quot;426 Upgrade Required&quot;,
&quot;500 Internal Server Error&quot;,
&quot;501 Method Not Implemented&quot;,
&quot;502 Bad Gateway&quot;,
&quot;503 Service Temporarily Unavailable&quot;,
&quot;504 Gateway Time-out&quot;,
&quot;505 HTTP Version Not Supported&quot;,
&quot;506 Variant Also Negotiates&quot;,
&quot;507 Insufficient Storage&quot;,
&quot;508 unused&quot;,
&quot;509 unused&quot;,
&quot;510 Not Extended&quot;</pre>
<h2>IANA HTTP Status Code Registry</h2>
<table cellpadding="3" cellspacing="0">
<thead>
<tr>
<th>Value</th>
<th>Description</th>
<th>Reference</th>
</tr>
</thead>
<tbody>
<tr>
<td>100</td>
<td>Continue</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.1.1" rel="nofollow" >Section 10.1.1</a> </td>
</tr>
<tr>
<td>101</td>
<td>Switching Protocols</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.1.2" rel="nofollow" >Section 10.1.2</a> </td>
</tr>
<tr>
<td>102</td>
<td>Processing</td>
<td> <a href="#RFC2518" rel="nofollow" ><cite title="HTTP Extensions for Distributed Authoring -- WEBDAV">[RFC2518]</cite></a> , <a href="http://rfc.askapache.com/rfc2518#section-10.1" rel="nofollow" >Section 10.1</a> </td>
</tr>
<tr>
<td>200</td>
<td>OK</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.1" rel="nofollow" >Section 10.2.1</a> </td>
</tr>
<tr>
<td>201</td>
<td>Created</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.2" rel="nofollow" >Section 10.2.2</a> </td>
</tr>
<tr>
<td>202</td>
<td>Accepted</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.3" rel="nofollow" >Section 10.2.3</a> </td>
</tr>
<tr>
<td>203</td>
<td>Non-Authoritative Information</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.4" rel="nofollow" >Section 10.2.4</a> </td>
</tr>
<tr>
<td>204</td>
<td>No Content</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.5" rel="nofollow" >Section 10.2.5</a> </td>
</tr>
<tr>
<td>205</td>
<td>Reset Content</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.6" rel="nofollow" >Section 10.2.6</a> </td>
</tr>
<tr>
<td>206</td>
<td>Partial Content</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.7" rel="nofollow" >Section 10.2.7</a> </td>
</tr>
<tr>
<td>207</td>
<td>Multi-Status</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.1" rel="nofollow" >Section 11.1</a> </td>
</tr>
<tr>
<td>226</td>
<td>IM Used</td>
<td> <a href="#RFC3229" rel="nofollow" ><cite title="Delta encoding in HTTP">[RFC3229]</cite></a> , <a href="http://rfc.askapache.com/rfc3229#section-10.4.1" rel="nofollow" >Section 10.4.1</a> </td>
</tr>
<tr>
<td>300</td>
<td>Multiple Choices</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.1" rel="nofollow" >Section 10.3.1</a> </td>
</tr>
<tr>
<td>301</td>
<td>Moved Permanently</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.2" rel="nofollow" >Section 10.3.2</a> </td>
</tr>
<tr>
<td>302</td>
<td>Found</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.3" rel="nofollow" >Section 10.3.3</a> </td>
</tr>
<tr>
<td>303</td>
<td>See Other</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.4" rel="nofollow" >Section 10.3.4</a> </td>
</tr>
<tr>
<td>304</td>
<td>Not Modified</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.5" rel="nofollow" >Section 10.3.5</a> </td>
</tr>
<tr>
<td>305</td>
<td>Use Proxy</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.6" rel="nofollow" >Section 10.3.6</a> </td>
</tr>
<tr>
<td>306</td>
<td>(Reserved)</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.7" rel="nofollow" >Section 10.3.7</a> </td>
</tr>
<tr>
<td>307</td>
<td>Temporary Redirect</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.8" rel="nofollow" >Section 10.3.8</a> </td>
</tr>
<tr>
<td>400</td>
<td>Bad Request</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.1" rel="nofollow" >Section 10.4.1</a> </td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.2" rel="nofollow" >Section 10.4.2</a> </td>
</tr>
<tr>
<td>402</td>
<td>Payment Required</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.3" rel="nofollow" >Section 10.4.3</a> </td>
</tr>
<tr>
<td>403</td>
<td>Forbidden</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.4" rel="nofollow" >Section 10.4.4</a> </td>
</tr>
<tr>
<td>404</td>
<td>Not Found</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.5" rel="nofollow" >Section 10.4.5</a> </td>
</tr>
<tr>
<td>405</td>
<td>Method Not Allowed</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.6" rel="nofollow" >Section 10.4.6</a> </td>
</tr>
<tr>
<td>406</td>
<td>Not Acceptable</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.7" rel="nofollow" >Section 10.4.7</a> </td>
</tr>
<tr>
<td>407</td>
<td>Proxy Authentication Required</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.8" rel="nofollow" >Section 10.4.8</a> </td>
</tr>
<tr>
<td>408</td>
<td>Request Timeout</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.9" rel="nofollow" >Section 10.4.9</a> </td>
</tr>
<tr>
<td>409</td>
<td>Conflict</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.10" rel="nofollow" >Section 10.4.10</a> </td>
</tr>
<tr>
<td>410</td>
<td>Gone</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.11" rel="nofollow" >Section 10.4.11</a> </td>
</tr>
<tr>
<td>411</td>
<td>Length Required</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.12" rel="nofollow" >Section 10.4.12</a> </td>
</tr>
<tr>
<td>412</td>
<td>Precondition Failed</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.13" rel="nofollow" >Section 10.4.13</a> </td>
</tr>
<tr>
<td>413</td>
<td>Request Entity Too Large</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.14" rel="nofollow" >Section 10.4.14</a> </td>
</tr>
<tr>
<td>414</td>
<td>Request-URI Too Long</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.15" rel="nofollow" >Section 10.4.15</a> </td>
</tr>
<tr>
<td>415</td>
<td>Unsupported Media Type</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.16" rel="nofollow" >Section 10.4.16</a> </td>
</tr>
<tr>
<td>416</td>
<td>Requested Range Not Satisfiable</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.17" rel="nofollow" >Section 10.4.17</a> </td>
</tr>
<tr>
<td>417</td>
<td>Expectation Failed</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.18" rel="nofollow" >Section 10.4.18</a> </td>
</tr>
<tr>
<td>422</td>
<td>Unprocessable Entity</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.2" rel="nofollow" >Section 11.2</a> </td>
</tr>
<tr>
<td>423</td>
<td>Locked</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.3" rel="nofollow" >Section 11.3</a> </td>
</tr>
<tr>
<td>424</td>
<td>Failed Dependency</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.4" rel="nofollow" >Section 11.4</a> </td>
</tr>
<tr>
<td>426</td>
<td>Upgrade Required</td>
<td> <a href="#RFC2817" rel="nofollow" ><cite title="Upgrading to TLS Within HTTP/1.1">[RFC2817]</cite></a> , <a href="http://rfc.askapache.com/rfc2817#section-6" rel="nofollow" >Section 6</a> </td>
</tr>
<tr>
<td>500</td>
<td>Internal Server Error</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.1" rel="nofollow" >Section 10.5.1</a> </td>
</tr>
<tr>
<td>501</td>
<td>Not Implemented</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.2" rel="nofollow" >Section 10.5.2</a> </td>
</tr>
<tr>
<td>502</td>
<td>Bad Gateway</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.3" rel="nofollow" >Section 10.5.3</a> </td>
</tr>
<tr>
<td>503</td>
<td>Service Unavailable</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.4" rel="nofollow" >Section 10.5.4</a> </td>
</tr>
<tr>
<td>504</td>
<td>Gateway Timeout</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.5" rel="nofollow" >Section 10.5.5</a> </td>
</tr>
<tr>
<td>505</td>
<td>HTTP Version Not Supported</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.6" rel="nofollow" >Section 10.5.6</a> </td>
</tr>
<tr>
<td>506</td>
<td>Variant Also Negotiates</td>
<td> <a href="#RFC2295" rel="nofollow" ><cite title="Transparent Content Negotiation in HTTP">[RFC2295]</cite></a> , <a href="http://rfc.askapache.com/rfc2295#section-8.1" rel="nofollow" >Section 8.1</a> </td>
</tr>
<tr>
<td>507</td>
<td>Insufficient Storage</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.5" rel="nofollow" >Section 11.5</a> </td>
</tr>
<tr>
<td>510</td>
<td>Not Extended</td>
<td> <a href="#RFC2774" rel="nofollow" ><cite title="An HTTP Extension Framework">[RFC2774]</cite></a> , <a href="http://rfc.askapache.com/rfc2774#section-7" rel="nofollow" >Section 7</a> </td>
</tr>
</tbody>
</table>
<h2>WordPress 2.8 Changes</h2>
<p>I just learned that <a href="https://core.trac.wordpress.org/ticket/9297" rel="nofollow" >my modification</a> to the WordPress core was <a href="https://core.trac.wordpress.org/changeset/10740" rel="nofollow" >accepted</a> and will be implemented for version 2.8!  This may mean WordPress is the only 100% HTTP/1.1 compliant software on the net!  Below is the new list (<em>I thought someone out there could use the php array</em>) and as you can see, unfortunately<strong>418 I&#8217;m a teapot</strong>didn&#8217;t make it ;)</p>
<pre>$wp_header_to_desc = array(
  100 =&gt; &#039;Continue&#039;,
  101 =&gt; &#039;Switching Protocols&#039;,
  102 =&gt; &#039;Processing&#039;,
&nbsp;
  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;,
  226 =&gt; &#039;IM Used&#039;,
&nbsp;
  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;Reserved&#039;,
  307 =&gt; &#039;Temporary Redirect&#039;,
&nbsp;
  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 Timeout&#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 Long&#039;,
  415 =&gt; &#039;Unsupported Media Type&#039;,
  416 =&gt; &#039;Requested Range Not Satisfiable&#039;,
  417 =&gt; &#039;Expectation Failed&#039;,
  422 =&gt; &#039;Unprocessable Entity&#039;,
  423 =&gt; &#039;Locked&#039;,
  424 =&gt; &#039;Failed Dependency&#039;,
  426 =&gt; &#039;Upgrade Required&#039;,
&nbsp;
  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 Timeout&#039;,
  505 =&gt; &#039;HTTP Version Not Supported&#039;,
  506 =&gt; &#039;Variant Also Negotiates&#039;,
  507 =&gt; &#039;Insufficient Storage&#039;,
  510 =&gt; &#039;Not Extended&#039;
);</pre>
<h2>RIPE WHOIS</h2>
<blockquote cite="http://labs.ripe.net/content/ripe-database-api-documentation">
<p><p>All the status codes are standard HTTP codes ( <a href="http://www.iana.org/assignments/http-status-codes" rel="nofollow" >http://www.iana.org/assignments/http-status-codes</a> ).</p>
</p>
<p>Clients should avoid any form of coupling with the the text/plain error message contained in response body since it may change between different releases of the API and is only intended as a starting point for indentifying the real causes of the exception event.</p>
<p>The following table gives a brief description of the mapping between standard Whois V.3 responses and the related REST services status codes. Consider this table as just an example of the error mapping strategy, it may change with future releases.</p>
</p>
</blockquote>
<table>
<tbody>
<tr>
<th>System Exception</th>
<th>Whois Error</th>
<th>HTTP Status Code</th>
</tr>
<tr>
<td>IllegalArgumentException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>IllegalStateException</td>
<td></td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>UnsupportedOperationException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>ObjectNotFoundException</td>
<td></td>
<td>Not Found (404)</td>
</tr>
<tr>
<td>IllegalStateException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>IOException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>SystemException</td>
<td></td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>TooManyResultsException</td>
<td></td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>No Entries Found (101)</td>
<td>Not Found (404)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Unknown Source (102)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Unknown Object Type (103)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Unknown Attribute in Query (104)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Attribute Is Not Inverse Searchable (105)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>No Search Key Specified (106)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Access Denied (201)</td>
<td>Forbidden (403)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Access Control Limit Reached (202)</td>
<td>Forbidden (403)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Address Passing Not Allowed (203)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Maximum Referral Lines Exceeded (204)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Connection Has Been Closed(301)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Referral Timeout (302)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>No Referral Host (303)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Referral Host Not Responding (304)</td>
<td>Internal Server Error (500)</td>
</tr>
</tbody>
</table>
<blockquote cite="http://labs.ripe.net/content/ripe-database-api-documentation">
<p><p>Clients will have to define error messages generic enough to represent the four main error conditions, that are Bad Request, Forbidden, Not Found and Internal Server Error.</p>
<p>For example a possible mapping for client side error messages may be:</p>
</p>
</blockquote>
<table>
<tbody>
<tr>
<th>HTTP Status Code</th>
<th>Error Message</th>
</tr>
<tr>
<td>Bad Request (400)</td>
<td>The service is unable to understand and process the query.</td>
</tr>
<tr>
<td>Forbidden (403)</td>
<td>Query limit exceeded.</td>
</tr>
<tr>
<td>Not Found (404)</td>
<td>No results were found for Your search &#8220;<tt>Search term</tt>&#8220;</td>
</tr>
<tr>
<td>Internal Server Error (500)</td>
<td>The server encountered an unexpected condition which prevented it from fulfilling the request.</td>
</tr>
</tbody>
</table>
<h2>Helpful HTTP Links</h2>
<ol>
<li> <a href="http://www.iana.org/assignments/http-status-codes" rel="nofollow" >IANA registry</a> </li>
<li> <a href="http://rfc.askapache.com/rfc2324" rel="nofollow" >Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)</a> </li>
<li> <a href="http://livedocs.adobe.com/fms/2/docs/00000338.html" rel="nofollow" >Adobe Flash status code definitions (ie 408)</a> </li>
<li> <a href="http://support.microsoft.com/?id=318380" rel="nofollow" >Microsoft Internet Information Server Status Codes and Sub-Codes</a> </li>
<li> <a href="http://zamez.org/httplint?url=http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">httplint</a> </li>
<li> <a href="http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html" rel="nofollow" >HTTP Headers, brief intro.</a> </li>
<li> <a href="http://www.w3.org/TR/cuap" rel="nofollow" >Common User-Agent Issues</a> </li>
<li>[RFC2295] <a href="mailto:koen@win.tue.nl" rel="nofollow"  title="Technische Universiteit Eindhoven">Holtman, K.</a> and <a href="mailto:mutz@hpl.hp.com" rel="nofollow"  title="Hewlett-Packard Company">A.H. Mutz</a> , &#8221; <a href="http://rfc.askapache.com/rfc2295" rel="nofollow" >Transparent Content Negotiation in HTTP</a> &#8220;, RFC 2295, March 1998.</li>
<li>[RFC2518] <a href="mailto:yarong@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Goland, Y.</a> , <a href="mailto:ejw@ics.uci.edu" rel="nofollow"  title="Dept. Of Information and Computer Science, University of California, Irvine">Whitehead, E.</a> , <a href="mailto:asad@netscape.com" rel="nofollow"  title="Netscape">Faizi, A.</a> , <a href="mailto:srcarter@novell.com" rel="nofollow"  title="Novell">Carter, S.R.</a> , and <a href="mailto:dcjensen@novell.com" rel="nofollow"  title="Novell">D. Jensen</a> , &#8221; <a href="http://rfc.askapache.com/rfc2518" rel="nofollow" >HTTP Extensions for Distributed Authoring &#8212; WEBDAV</a> &#8220;, RFC 2518, February 1999.</li>
<li>[RFC2616] <a href="mailto:fielding@ics.uci.edu" rel="nofollow"  title="University of California, Irvine">Fielding, R.</a> , <a href="mailto:jg@w3.org" rel="nofollow"  title="W3C">Gettys, J.</a> , <a href="mailto:mogul@wrl.dec.com" rel="nofollow"  title="Compaq Computer Corporation">Mogul, J.</a> , <a href="mailto:frystyk@w3.org" rel="nofollow"  title="MIT Laboratory for Computer Science">Frystyk, H.</a> , <a href="mailto:masinter@parc.xerox.com" rel="nofollow"  title="Xerox Corporation">Masinter, L.</a> , <a href="mailto:paulle@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Leach, P.</a> , and <a href="mailto:timbl@w3.org" rel="nofollow"  title="W3C">T. Berners-Lee</a> , &#8221; <a href="http://rfc.askapache.com/rfc2616" rel="nofollow" >Hypertext Transfer Protocol &#8212; HTTP/1.1</a> &#8220;, RFC 2616, June 1999.</li>
<li>[RFC2774] <a href="mailto:frystyk@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Nielsen, H.</a> , <a href="mailto:paulle@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Leach, P.</a> , and <a href="mailto:lawrence@agranat.com" rel="nofollow"  title="Agranat Systems, Inc.">S. Lawrence</a> , &#8221; <a href="http://rfc.askapache.com/rfc2774" rel="nofollow" >An HTTP Extension Framework</a> &#8220;, RFC 2774, February 2000.</li>
<li>[RFC2817] Khare, R. and S. Lawrence, &#8221; <a href="http://rfc.askapache.com/rfc2817" rel="nofollow" >Upgrading to TLS Within HTTP/1.1</a> &#8220;, RFC 2817, May 2000.</li>
<li>[RFC3229] Mogul, J., Krishnamurthy, B., Douglis, F., Feldmann, A., Goland, Y., van Hoff, A., and D. Hellerstein, &#8221; <a href="http://rfc.askapache.com/rfc3229" rel="nofollow" >Delta encoding in HTTP</a> &#8220;, RFC 3229, January 2002.</li>
<li>[RFC4918] <a href="mailto:ldusseault@commerce.net" rel="nofollow"  title="CommerceNet">Dusseault, L., Ed.</a> , &#8221; <a href="http://rfc.askapache.com/rfc4918" rel="nofollow" >HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)</a> &#8220;, RFC 4918, June 2007.</li>
</ol>
<p><a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html"></a><a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">HTTP Status Codes and .htaccess ErrorDocuments</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Vetted &#8211; Top 3 WordPress Speed Plugins</title>
		<link>http://www.askapache.com/wordpress/fastest-caching-plugins.html</link>
		<comments>http://www.askapache.com/wordpress/fastest-caching-plugins.html#comments</comments>
		<pubDate>Sun, 29 Nov 2009 19:14:16 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[AskApache Crazy Cache]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[Bottleneck]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Private Server]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[WordPress Optimizing]]></category>
		<category><![CDATA[WordPress Speed]]></category>
		<category><![CDATA[WP-Super Cache]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3701</guid>
		<description><![CDATA[<p><a class="IFL" id="id15" href="http://www.askapache.com/wordpress/fastest-caching-plugins.html" title="Top 3 WordPress Plugins for a Faster Blog"></a>There are so many WordPress plugins out there now that I wanted to post my favorite 3 plugins for speeding up a WP-Powered blog.  These are the 3 plugins that I install for pretty much all of my WP-Powered sites, which I run about 300 now.  They work together to provide a very optimized blog for speed.<br /><br /><strong>DB-Cache Reloaded does something entirely different</strong>, it saves the mysql queries that are made to the WP-database, as well as the mysql results to static files, and then through php serves those cached-files instead of re-querying the mysql database. Most mysql databases are stored on separate servers, and although many are on the same local network there is a limit to how many queries, and how many connections can take place.<br /><br />So DB-Cache Reloaded basically makes WP-Super Cache work alot faster when generating the cache files, and DB-Cache Reloaded helps in a number of areas un-related to WP-Super Cache, like in the admin panel.  And DB-Cache without WP-Super-Cache is a joke because it still uses the application-level and php for everything.  <em>Gotta use both (or just WPSC)</em>.<br class="C" /></p>
]]></description>
			<content:encoded><![CDATA[<p>There are so many WordPress plugins out there now that I wanted to post my favorite 3 plugins for speeding up a WP-Powered blog (including one of <a href="http://wordpress.org/extend/plugins/profile/askapache" rel="nofollow" >my plugins</a>).  These are the 3 plugins that I install for pretty much all of my WP-Powered sites, which I run about 300 now.  They work together to provide a very optimized blog for speed.</p>
<h2>Top 3 WordPress Speed Plugins</h2>
<ol class="TOC">
<li><a href="http://www.askapache.com/wordpress/fastest-caching-plugins.html#db-cache-reloaded">DB Cache Reloaded</a></li>
<li><a href="http://www.askapache.com/wordpress/fastest-caching-plugins.html#wp-super-cache">WP Super Cache</a></li>
<li><a href="http://www.askapache.com/wordpress/fastest-caching-plugins.html#crazy-cache">AskApache Crazy Cache</a></li>
</ol>
<h2>WP Caching Overview</h2>
<p>Each request to your blog has to fire up the php interpreter and query the mysql database to create the output that you see in your browser.  Using a plugin like WP Super Cache simply saves the output of that request as a static HTML file and serves that to a request instead of using php and mysql every time.  DB Cache Reloaded takes this a step further by optimizing the mysql queries.  Finally, AskApache Crazy Cache is used to keep a cache fully primed and ready.</p>
<h3>Why Caching?</h3>
<p>If you have a private server, or you want to keep your MEMORY, BANDWIDTH, and CPU usage down for your server, these plugins will be dramatic.  If you have a site that is updated maybe once a month and gets a very small amount of traffic, then the AskApache Crazy Cache would be redundant.  That plugin is geared for the heaviest traffic sites.</p>
<h3>Request and Response</h3>
<p>Most HTTP communication is initiated by a user agent (browser) and consists of a request to a resource on some origin server. In the simplest case, this may be accomplished via a single connection (v) between the user agent (UA) and the origin server (O).</p>
<pre>             request chain &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&gt;
          UA &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-v&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- O
             &lt;&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;- response chain</pre>
<p>If a browser requests a WP-driven page, the server generates the response (the outputted html) by loading a php interpreter or module to read the WP php files and load all the settings.  WP stores the settings in a mysql database and has to query the mysql database for all the data (like the content of your post that becomes html).  Finally php sends the output through the server back to the browser.  This is the norm for most PHP applications.  Every time an interpreter is loaded additional CPU and Memory are used.  And perhaps even more troublesome for shared-hosting using a virtual or network filesystem, each load causes many hard-disk accesses, additional processes, etc.</p>
<h3>Cache PHP</h3>
<p>By saving the php-generated output of a page to a static html file, your server can entirely skip loading a php interpreter or other process.  Originally servers were needed and created to essentially open a static file on disk and send that file back to the requesting user.  So servers are specialized for this as it&#8217;s their core function.</p>
<p><strong>WP-Super cache does this for you by saving the output into a static html file</strong>, and by instructing the server to skip loading php.  It basically only uses php for creating the cached version, in the same way that you can save this webpage as an html file, WP-Super cache saves all the WP-blog permalinks to static files.</p>
<p><strong>DB-Cache Reloaded does something entirely different</strong>, it saves the mysql queries that are made to the WP-database, as well as the mysql results to static files, and then through php serves those cached-files instead of re-querying the mysql database. Most mysql databases are stored on separate servers, and although many are on the same local network there is a limit to how many queries, and how many connections can take place.  But mysql is maybe the fastest thing I&#8217;ve seen, so your bottlenecks almost never happen there (if configured correctly).</p>
<p>So DB-Cache Reloaded basically makes WP-Super Cache work alot faster when generating the cache files, and DB-Cache Reloaded helps in a number of areas un-related to WP-Super Cache, like in the admin panel.  And DB-Cache without WP-Super-Cache is a joke because it still uses the application-level and php for everything.  <em>Gotta use both (or just WPSC)</em>.</p>
<p><strong>AskApache Crazy Cache is a plugin I wrote</strong> to do one thing very well, it runs at intervals via the WP-cron and forces WP-Super-Cache to create a static cache file for all the posts, pages, etc. on your site.  Without this WPSC likes to do dumb things like try to manage it&#8217;s own cache with stale files and expired files, which equals a lot more php interpreters getting loaded instead of cached static files.  For sites with more than a visit/page/10minutes this plugin keeps a full primed cache built by WPSC.</p>
<h3>Compression and WP-Super Cache</h3>
<p><strong>Enabling compression in WP-Super Cache</strong> is almost always a great idea.  I&#8217;ve never had a problem other than some php compat issues with not-updated php installations.  This option basically lets WP-Super Cache compress the generated output of a page and save that to the static file.  Normally Apache, Lighttpd, Nginx, etc. open the static file and compress it before it is sent to the browser, then the browser automatically decompresses it to view.  This happens so fast because it is run by the server.</p>
<p>This lets WPSC instruct your server to send the compressed version to all browsers that accept compression, and send the uncompressed static file to any other browsers.  So this is helpful because it eliminates your server having to do any transparent compressing, it can instead just focus on what it does best, serving static files.</p>
<p>PHP is an application so it requires memory, hard-drive access, and CPU time.  Check out the protocol hierarchy:</p>
<pre>       +&#45;&#45;-&#45;&#45;-+ +&#45;&#45;&#45;&#45;-+ +&#45;&#45;&#45;&#45;-+       +&#45;&#45;&#45;&#45;-+
       |Telnet| | FTP | |Voice|  &#46;..  |     |  Application Level
       +&#45;&#45;-&#45;&#45;-+ +&#45;&#45;&#45;&#45;-+ +&#45;&#45;&#45;&#45;-+       +&#45;&#45;&#45;&#45;-+
             |   |         |             |
            +&#45;&#45;&#45;&#45;-+     +&#45;&#45;&#45;&#45;-+       +&#45;&#45;&#45;&#45;-+
            | TCP |     | RTP |  &#46;..  |     |  Host Level
            +&#45;&#45;&#45;&#45;-+     +&#45;&#45;&#45;&#45;-+       +&#45;&#45;&#45;&#45;-+
               |           |             |
            +&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-+
            |    Internet Protocol &amp; ICMP   |  Gateway Level
            +&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-+
                           |
              +&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-+
              |   Local Network Protocol  |    Network Level
              +&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-+       </pre>
<p><a id="db-cache-reloaded" name="db-cache-reloaded"></a></p>
<h3>DB Cache Reloaded</h3>
<p><a href="http://wordpress.org/extend/plugins/db-cache-reloaded/" rel="nofollow" >DB Cache Reloaded Plugin Page</a> &#8211; <a href="http://wordpress.org/tags/db-cache-reloaded?forum_id=10" rel="nofollow" >News</a></p>
<p><a href="http://uploads.askapache.com/2009/11/db-cache-reloaded.png" rel="nofollow" class="IFL" ><img src="http://uploads.askapache.com/2009/11/db-cache-reloaded-116x64.png" alt="DB Cache Reloaded" title="DB Cache Reloaded" width="116" height="64" /></a>This plugin caches every database query with given lifetime. It is much faster than other html caching plugins and uses less disk space for caching.</p>
<p>I think you&#8217;ve heard of WP-Cache or WP Super Cache, they are both top plugins for WordPress, which make your site faster and responsive. Forget about them &#8211; with DB Cache Reloaded your site will work much faster and will use less disk space for cached files. Your visitors will always get actual information in sidebars and server CPU loads will be as low as possible.<br class="C" /></p>
<blockquote cite="http://wordpress.org/extend/plugins/db-cache-reloaded/faq/">
<h4>Why is DB Cache Reloaded better than WP Super Cache?</h4>
<p>This plugin is based on a fundamentally different principle of caching queries to database instead of full pages, which optimises WordPress from the very beginning and uses less disk space for cache files because it saves only useful information. It saves information separately and also caches hidden requests to database.</p>
</blockquote>
<p><a id="wp-super-cache" name="wp-super-cache"></a></p>
<h3>WP Super Cache</h3>
<p><a href="http://wordpress.org/extend/plugins/wp-super-cache/" rel="nofollow" >WP Super Cache Plugin Page</a> &#8211; <a href="http://wordpress.org/tags/wp-super-cache?forum_id=10" rel="nofollow" >News</a></p>
<p><a href="http://uploads.askapache.com/2009/11/wp-super-cache.png" rel="nofollow" class="IFL" ><img src="http://uploads.askapache.com/2009/11/wp-super-cache-116x61.png" alt="WP Super Cache" title="WP Super Cache" width="116" height="61" /></a>This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.</p>
<p>The static html files will be served to the vast majority of your users, but because a user&#8217;s details are displayed in the comment form after they leave a comment those requests are handled by PHP. Static files are served to:</p>
<p>&middot; Users who are not logged in.<br />&middot; Users who have not left a comment on your blog.<br />&middot; Or users who have not viewed a password protected post.</p>
<p>99% of your visitors will be served static html files. Those users who don&#8217;t see the static files will still benefit because they will see regular WP-Cache cached files and your server won&#8217;t be as busy as before. This plugin will help your server cope with a front page appearance on digg.com or other social networking site.<br class="C" /></p>
<blockquote cite="http://wordpress.org/extend/plugins/wp-super-cache/faq/">
<h4>Why is WP-Super-Cache better than WP-Cache?</h4>
<p>This plugin is based on the excellent WP-Cache plugin and therefore brings all the benefits of that plugin to WordPress. On top of that it creates copies of every page that is accessed on a blog in a form that is quickly served by the web server. It&#8217;s almost as quick as if the you had saved a page in your browser and uploaded it to replace your homepage.</p>
</blockquote>
<blockquote cite="http://wordpress.org/extend/plugins/wp-super-cache/faq/">
<h4>Will the Super Cache compression slow down my server?</h4>
<p>No, it will do the opposite in fact. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor&#8217;s browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.</p>
</blockquote>
<p><a id="crazy-cache" name="crazy-cache"></a></p>
<h3>AskApache Crazy Cache</h3>
<p><a href="http://wordpress.org/extend/plugins/askapache-crazy-cache/" rel="nofollow" >AskApache Crazy Cache Plugin Page</a> &#8211; <a href="http://wordpress.org/tags/askapache-crazy-cache?forum_id=10" rel="nofollow" >News</a></p>
<blockquote cite="http://wordpress.org/extend/plugins/askapache-crazy-cache/">
<p>
<p><a href="http://uploads.askapache.com/2009/11/askapache-crazy-cache.png" rel="nofollow" class="IFL" ><img src="http://uploads.askapache.com/2009/11/askapache-crazy-cache-116x36.png" alt="AskApache Crazy Cache" title="AskApache Crazy Cache" width="116" height="36" /></a>This sweet little plugin does one thing very well. It caches all the posts on your entire blog at the same time, if you are using WP-Cache, WP-Super-Cache, or Hyper-Cache.<br class="C" /></p>
</p>
</blockquote>
<pre>
                              +&#45;&#45;-&#45;&#45;-&#45;&#45;-+ &#45;&#45;-&#45;&#45;-&#45;&#45;-\      active OPEN
                              |  CLOSED |            \    &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-
                              +&#45;&#45;-&#45;&#45;-&#45;&#45;-+&lt;&#45;&#45;-&#45;&#45;-&#45;&#45;-\   \   create TCB
                                |     ^              \   \  snd SYN
                   passive OPEN |     |   CLOSE        \   \
                   &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- |     | &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-       \   \
                    create TCB  |     | delete TCB         \   \
                                V     |                      \   \
                              +&#45;&#45;-&#45;&#45;-&#45;&#45;-+            CLOSE    |    \
                              |  LISTEN |          &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- |     |
                              +&#45;&#45;-&#45;&#45;-&#45;&#45;-+          delete TCB |     |
                   rcv SYN      |     |     SEND              |     |
                  &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-   |     |    &#45;&#45;-&#45;&#45;&#45;-            |     V
 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+      snd SYN,ACK  /       \   snd SYN          +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
 |         |&lt;&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-           &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&gt;|         |
 |   SYN   |                    rcv SYN                     |   SYN   |
 |   RCVD  |&lt;&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-|   SENT  |
 |         |                    snd ACK                     |         |
 |         |&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-           &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-|         |
 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+   rcv ACK of SYN  \       /  rcv SYN,ACK       +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
   |           &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-   |     |   &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-
   |                  x         |     |     snd ACK
   |                            V     V
   |  CLOSE                   +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
   | &#45;&#45;-&#45;&#45;&#45;-                  |  ESTAB  |
   | snd FIN                  +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
   |                   CLOSE    |     |    rcv FIN
   V                  &#45;&#45;-&#45;&#45;&#45;-   |     |    &#45;&#45;-&#45;&#45;&#45;-
 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+          snd FIN  /       \   snd ACK          +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
 |  FIN    |&lt;&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-           &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&gt;|  CLOSE  |
 | WAIT-1  |&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-                              |   WAIT  |
 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+          rcv FIN  \                            +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
   | rcv ACK of FIN   &#45;&#45;-&#45;&#45;&#45;-   |                            CLOSE  |
   | &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;-   snd ACK   |                           &#45;&#45;-&#45;&#45;&#45;- |
   V        x                   V                           snd FIN V
 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+                  +&#45;&#45;-&#45;&#45;-&#45;&#45;-+                   +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
 |FINWAIT-2|                  | CLOSING |                   | LAST-ACK|
 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+                  +&#45;&#45;-&#45;&#45;-&#45;&#45;-+                   +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
   |                rcv ACK of FIN |                 rcv ACK of FIN |
   |  rcv FIN       &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;- |    Timeout=2MSL &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;&#45;- |
   |  &#45;&#45;-&#45;&#45;&#45;-              x       V    &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-        x       V
    \ snd ACK                 +&#45;&#45;-&#45;&#45;-&#45;&#45;-+delete TCB         +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
     &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&gt;|TIME WAIT|&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&gt;| CLOSED  |
                              +&#45;&#45;-&#45;&#45;-&#45;&#45;-+                   +&#45;&#45;-&#45;&#45;-&#45;&#45;-+
&nbsp;
                      TCP Connection State Diagram</pre>
<p><a href="http://www.askapache.com/wordpress/fastest-caching-plugins.html"></a><a href="http://www.askapache.com/wordpress/fastest-caching-plugins.html">Vetted &#8211; Top 3 WordPress Speed Plugins</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/wordpress/fastest-caching-plugins.html/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Optimizing Servers and Processes for Speed with ionice, nice, ulimit</title>
		<link>http://www.askapache.com/linux-unix/optimize-nice-ionice.html</link>
		<comments>http://www.askapache.com/linux-unix/optimize-nice-ionice.html#comments</comments>
		<pubDate>Sat, 10 Oct 2009 05:41:28 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[503]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Blocking]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[Bottleneck]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Disk IO]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[fifo]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[iostat]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[pagefile]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Renice]]></category>
		<category><![CDATA[Round Robin]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[Socket]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[taskset]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Ulimit]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp-config.php]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3167</guid>
		<description><![CDATA[<p><a href="http://www.askapache.com/linux-unix/optimize-nice-ionice.html" class="IFL" id="id18"></a>To prepare for several upcoming articles on AskApache that are focused on optimizing Servers and Sites from a server admin level, here is an article to introduce the main tools that we will be using.  These tools are used to optimize CPU time for each process using <strong>nice</strong> and <strong>renice</strong>, and other tools like <strong>ionice</strong> are used to optimize the Disk IO, or Disk speed / Disk traffic for each process.  Then you can make sure your mysqld and httpd processes are always fast and prioritized.<br class="C" /></p> ]]></description>
			<content:encoded><![CDATA[<p>Ok, sup.  I really felt I had to get this out of the way, because I have a whole stack of drafts waiting to be published, but I realized that not many people will benefit from all the advanced optimizations and tricks I&#8217;m writing unless they get a basic understanding of some of the tools I&#8217;m using.  I decided to write a series of articles explaining how I optimize servers for speed because lately I&#8217;ve been getting a lot more people wanting to hire me to do that.  I take on projects when I can but there is clearly a need out here on the net for some self-help.   The momentum is swinging more and more towards VPS type of web hosting, and I would say that 99% of those customers are getting supremely ripped off, which goes against the foundation of the web.</p>
<p>Keep in mind that this blog and my research is only a hobby of mine, my job is primarily marketing and sales, so I&#8217;m not some licensed expert or anything, or even an unlicensed expert! haha.  But it does bother me that those who are tech-savvy enough to run web-hosting companies are happily ripping people off.  So this article details the main tools that are used to speed up and optimize your machine by delegating levels of priority to specific processes.  Future articles will use these tools alot, so this is meant as an intro.</p>
<p><a id="cpu-disk-io" name="cpu-disk-io"></a></p>
<h2>CPU and Disk I/O</h2>
<p>As most of you are aware, there are 2 variables that determine any computer or programs speed.  CPU and Disk I/O.  CPU determines how fast you can process data, crunch numbers, etc. while disk I/O determines how fast your disks can read and write data to the hard-drive.  Wouldn&#8217;t it be great if you could easily configure your server to give your httpd, php, and other processes both greater CPU processing and disk IO than your non-important processes like backup scripts, ftp daemons, etc.?  We are talking about Linux in this article, so of course YES not only can you do that, you should!</p>
<p><a name="optimize-ram" id="optimize-ram"></a></p>
<h3>RAM</h3>
<p>RAM is like a hard-drive in that data is stored on it, and read/written to it.  The difference is that RAM is somewhere around 30x faster than disk I/O, but the cost of that incredible speed is that the data stored on it is only temporary in the sense that it won&#8217;t be stored permanently, it is completely erased when your machine is rebooted.  RAM is also expensive, and there is a limit to how much a server or machine can have due to hardware limits.</p>
<p><a name="optimize-swap" id="optimize-swap"></a></p>
<h3>SWAP</h3>
<p>SWAP takes off when you run out of RAM but you still want certain data to be read/write quickly.  Basically when you start running out of RAM your machine starts supplementing RAM with SWAP storage.  SWAP is usually a partition on a second hard-drive disk.  There is an upper limit on how much I/O can occur on a disk at one time, and the more I/O takes place, the slower all I/O becomes, so SWAP works well on a separate hard-drive as it will have much faster I/O.  On Windows they opted to copy the SWAP mechanism but instead use a file named pagefile.sys, and that is just one reason people in the know do not care for Windows.</p>
<p><a name="optimize-cpu" id="optimize-cpu"></a></p>
<h3>CPU</h3>
<p>So lets do this, think of your CPU (your processor) as having an amount of 100% processing available when not being used, 0% when its maxed out.  CPU&#8217;s handle multiple processing tasks simultaneously, so what we will discuss in this article is how to specify HOW MUCH of that processing amount each of your programs (heretofore &#8220;processes&#8221;) are able to use.  Yes, very very cool.</p>
<p>That is correct, you can easily configure your server to provide more of the available processing time to certain programs over others, like you can configure apache and php to utilize 50% of your CPU processing time by themselves, so that all other processes (proftpd, sshd, rsync, etc.) combined can only utilize 50%.  The terminology is we can give certain specific processes (like php.cgi, httpd, fast-cgi.cgi) a specific <strong>priority</strong>, where -19 is the most priority, and +19 is the least amount of priority, or CPU processing time.  I know it seems backwards.. </p>
<p><a id="tools" name="tools"></a></p>
<h2>The Tools</h2>
<p>If you run Windows, you are in the right place&#8230; because the following advice will save your life:  GET LINUX! Ok, now that that is out of the way, the following are the tools dicussed on this page.  All of them are free, open-source, and wonderful.  The basic idea of these tools is to control how much CPU is devoted to each process, and also how much Disk IO/Disk traffic is given to each process.</p>
<dl>
<dt><a href="#nice-tool" rel="nofollow" >nice</a></dt>
<dd>run a program with modified scheduling priority</dd>
<dt><a href="#renice-tool" rel="nofollow" >renice</a></dt>
<dd>alter priority of running processes</dd>
<dt><a href="#ionice-tool" rel="nofollow" >ionice</a></dt>
<dd>set or retrieve the I/O priority for a given pid or execute a new task with a given I/O priority.</dd>
<dt><a href="#iostat-tool" rel="nofollow" >iostat</a></dt>
<dd>Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.</dd>
<dt><a href="#ulimit-tool" rel="nofollow" >ulimit</a></dt>
<dd>Ulimit provides control over the resources available to processes started by the shell, on systems that allow such control.</dd>
<dt><a href="#chrt-tool" rel="nofollow" >chrt</a></dt>
<dd>set or retrieve real-time scheduling parameters for a given pid or execute a new task under given scheduling parameters.</dd>
<dt><a href="#taskset-tool" rel="nofollow" >taskset</a></dt>
<dd>set or retrieve task CPU affinity for a given pid or execute a new task under a given affinity mask.</dd>
<dt></dt>
<dd></dd>
</dl>
<p><a id="part1-processes" name="part1-processes"></a></p>
<h2>Part 1: Process Processes Faster</h2>
<p>Ok so lets tackle figuring out how to give your response-intensive processes (like apache, php, ruby, perl, java) meaning a request to your server/machine requires a <em>response</em>.  For instance, when you requested this page that you are reading at this very second, several things on my server had to happen for you to be able to read this.</p>
<p>First your computer sends out a request to see what server the www.askapache.com domain name is.  DNS servers respond with my server IP, so for servers dedicated as nameservers, optimizing the DNS processes like bind would speed that up.  Now that your computer knows how to reach my server it sends an HTTP GET request for this url.  This request is received by the httpd process that is apache, and apache determines this url should be handled by my custom compiled php5.3.0 binary, because this page is WordPress generated.  So the php binary loads up the WordPress /index.php file, which chain-loads several other php files, including <code>wp-config.php</code> containing my MySql database settings.  Now php connects to my MySql Server to fetch this articles content, comments, title, tags, etc. and then generates the HTML and hands that back to Apache.</p>
<p>Finally, Apache generates a HTTP RESPONSE and sends the RESPONSE and CONTENT back to your Browser, which then in turn renders the page for your eyes with the necessary javascript, images, css, and other files included in the HTML response.</p>
<h3>Too much Processing</h3>
<p>Now you see why I&#8217;ve opted to write my own caching plugin that takes the php and mysql processes OUT of that equation.  Both the php binary and the mysql instance consume CPU processing, and disk IO, to load all their library files, make various network requests and sockets, check permissions, and on and on.  And that&#8217;s completely ok, the thing is, unless you configure these processes (Apache, PHP, MySQL) they will use the same amount of CPU processing that other processes use, other processes that have very little to do with you reading this sentence.  Processes to run my mail server, my FTP server, my SSH server, my cronjobs, cleanup scripts, atd daemon, etc.. and they will get the same amount of CPU!</p>
<p>Another even simpler example is what got me to look into this myself.  I wrote a shell script that created hourly, daily, weekly, and monthly backups for all of my websites and sql databases, and set it up to run by cronjob at those set intervals.  Eventually I noticed my sites were slower, my php even slower, and sometimes I even saw 503 errors that my host throws up when my server is overloaded.  The research that I pursued to prevent that from happening has been hugely eye-opening.  What does a backup script do?  Mine just created tar archives of all the files in my web root, then gzipped the tar archive saving to a backup server using scp (a file transfer using ssh).  This resulted in the following huge problems that seem to have nothing to do with a faster server and speedier website, but they have everything to with it.</p>
<ol>
<li><strong>CPU Bottleneck #1</strong> &#8211; tar and gzip use compression algorithms at a low level to create a compressed version, and all that compressing uses a whole lot of crunching &#8211; CPU processing</li>
<li><strong>DISK IO Bottleneck</strong> &#8211; Tarring the whole web root directory was creating a ton of disk io, and remember the more disk io that is going on, the less is available for everything else.</li>
<li><strong>CPU Bottleneck #2</strong> &#8211; Using scp to send my backups was security-smart, but these huge archive files had to be encrypted and sent over the net.</li>
</ol>
<p><a id="breaking-bottlenecks" name="breaking-bottlenecks"></a></p>
<h2>Breaking Bottles</h2>
<p>I apologize for being a little long-winded there, but I think it&#8217;s important to make sure everyone understands those basic concepts, which are foreign to most people.  Once you understand what is causing the bottlenecks, then you can understand the solutions, which actually are incredibly simple and even a novice linux user can easily do.  Besides, the net gets a little bit faster every time someone implements this.</p>
<p><a id="nice-tool" name="nice-tool"></a></p>
<h3>nice</h3>
<p><img src="http://uploads.askapache.com/2009/10/nice-chart.png" alt="NICE Levels Chart" title="NICE Levels Chart" width="351" height="225" class="IFL" />Nice allows you to run a program with modified scheduling priority which specifies how much CPU is devoted to a particular process.  Run COMMAND with an adjusted niceness, which affects process scheduling.  With no COMMAND, print the current niceness.  </p>
<p>Nicenesses range from -20 (most favorable scheduling) to 19 (least favorable).   <code>-n, --adjustment=N</code> &#8211;  add integer N to the niceness (default 10).   <code>nice +19</code> tasks get a HZ-independent 1.5%.  Running a <code>nice +10</code> and a <code>nice +11</code> task means the first will get 55% of the CPU, the other 45%.<br class="C" /></p>
<p><a id="nice-usage" name="nice-usage"></a></p>
<h4>nice usage</h4>
<pre>nice [OPTION] [COMMAND [ARG]&#46;..]
&nbsp;
-n, &#45;-adjustment=ADJUST   increment priority by ADJUST first</pre>
<p><a id="nice-examples" name="nice-examples"></a></p>
<h4>Examples of nice</h4>
<p>Using nice to download a file</p>
<pre>nice -n 17 curl -q -v -A &#039;Mozilla/5.0&#039; -L -O http://wordpress.org/latest.zip</pre>
<p>Unzipping a file with nice</p>
<pre>nice -n 17 unzip latest.zip</pre>
<p>Nice way to build from source</p>
<pre>nice -n 2 ./configure
nice -n 2 make
nice -n 2 make install</pre>
<p>It is sometimes useful to run non-interactive programs with reduced priority.</p>
<pre>$ nice factor `echo &#039;2^9 - 1&#039;|bc`
511: 7 73</pre>
<p>Since nice prints the current priority, we can invoke it through itself to demonstrate how it works: The default behavior is to reduce priority by 10.</p>
<pre> $ nice nice
10
$ nice -n 10 nice
10</pre>
<p> The ADJUSTMENT is relative to the current priority.  The first <code>nice</code> invocation runs the second one at priority 10, and it in turn runs the final one at a priority lowered by 3 more.</p>
<pre>$ nice nice -n 3 nice
13</pre>
<p>Specifying a priority larger than 19 is the same as specifying 19.</p>
<pre>$ nice -n 30 nice
19</pre>
<p>Only a privileged user may run a process with higher priority.</p>
<pre>$ nice -n -1 nice
nice: cannot set priority: Permission denied
$ sudo nice -n -1 nice
-1</pre>
<blockquote cite="http://uploads.askapache.com/2009/08/sched-nice-design.txt">
<p>The new scheduler in v2.6.23 addresses all three types of complaints:</p>
<p>To address the first complaint (of nice levels being not &#8220;punchy&#8221; enough), the scheduler was decoupled from &#8216;time slice&#8217; and HZ concepts (and granularity was made a separate concept from nice levels) and thus it was possible to implement better and more consistent nice +19 support: with the new scheduler nice +19 tasks get a HZ-independent 1.5%, instead of the variable 3%-5%-9% range they got in the old scheduler.</p>
<p>To address the second complaint (of nice levels not being consistent), the new scheduler makes nice(1) have the same CPU utilization effect on tasks, regardless of their absolute nice levels. So on the new scheduler, running a nice +10 and a nice 11 task has the same CPU utilization &#8220;split&#8221; between them as running a nice -5 and a nice -4 task. (one will get 55% of the CPU, the other 45%.) That is why nice levels were changed to be &#8220;multiplicative&#8221; (or exponential) &#8211; that way it does not matter which nice level you start out from, the &#8216;relative result&#8217; will always be the same.</p>
<p>The third complaint (of negative nice levels not being &#8220;punchy&#8221; enough and forcing audio apps to run under the more dangerous SCHED_FIFO scheduling policy) is addressed by the new scheduler almost automatically: stronger negative nice levels are an automatic side-effect of the recalibrated dynamic range of nice levels.</p>
</blockquote>
<p><a id="renice-tool" name="renice-tool"></a></p>
<h3>renice</h3>
<p>Renice is similar to the nice command, but it lets you modify the nice of a currently running process.  This is nice for shell scripts where you can add this to the top of the script to nicify the whole script to 19.</p>
<p><a id="renice-usage" name="renice-usage"></a></p>
<h4>renice usage</h4>
<pre>renice priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]
&nbsp;
-g      Force who parameters to be interpreted as process group ID&#039;s.
-u      Force the who parameters to be interpreted as user names.
-p      Resets the who interpretation to be (the default) process ID&#039;s.</pre>
<p><a id="renice-examples" name="renice-examples"></a></p>
<h4>Examples of renice</h4>
<p>From the shell, changes the priority of the shell and all children to 19.  From a shell script, does the same but only for the script and its children.</p>
<pre>renice 19 -p $$</pre>
<p>This runs renice without any output</p>
<pre>renice 19 -p $$ &amp;&gt;/dev/null</pre>
<p>10 gets more CPU than 19</p>
<pre>renice 10 -p $$</pre>
<p>change the priority of process ID&#8217;s 987 and 32, and all processes owned by users daemon and root.</p>
<pre>renice +1 987 -u daemon root -p 32</pre>
<p><a id="part2-disk-io" name="part2-disk-io"></a></p>
<h2>Part 2: Optimizing Disk I/O</h2>
<p><a id="scheduling-policies" name="scheduling-policies"></a></p>
<h3>Linux Scheduling Policies</h3>
<p>The scheduler is the kernel component that decides which runnable process will be executed by the CPU next.  Each process has an associated scheduling policy and a static scheduling priority, sched_priority</p>
<p>Processes scheduled under one of the real-time policies (SCHED_FIFO, SCHED_RR) have a sched_priority value in the <strong>range 1 (low) to 99 (high)</strong>.  (As the numbers imply, real-time processes always have higher priority than normal processes.)   The following &#8220;real-time&#8221; policies are also supported, for special time-critical applications that need precise control over the way in which runnable processes are selected for execution:</p>
<p>Currently, Linux supports the following &#8220;normal&#8221; (i.e., non-real-time) scheduling policies:</p>
<dl>
<dt><strong>SCHED_OTHER</strong>: Default Linux time-sharing scheduling</dt>
<dd>The standard round-robin time-sharing policy</dd>
<dt><strong>SCHED_BATCH</strong>: Scheduling batch processes</dt>
<dd>This policy is useful for workloads that are non-interactive, but do not want to lower their nice value, and for workloads that want a deterministic scheduling policy without interactivity causing extra preemptions (between the workload&#8217;s tasks).</dd>
<dt><strong>SCHED_IDLE</strong>: Scheduling very low priority jobs</dt>
<dd>This policy is intended for running jobs at extremely low priority (lower even than a +19 nice value with the SCHED_OTHER or SCHED_BATCH policies)</dd>
<dt><strong>SCHED_FIFO</strong>: First In-First Out scheduling</dt>
<dd>A first-in, first-out policy</dd>
<dt><strong>SCHED_RR</strong>: Round Robin scheduling</dt>
<dd>A round-robin policy.</dd>
</dl>
<p><a id="scheduling-classes" name="scheduling-classes"></a></p>
<h3>Scheduling Classes</h3>
<dl>
<dt><code>IOPRIO_CLASS_RT</code></dt>
<dd>This is the realtime io class. The RT scheduling class is given first access to the disk, regardless of what else is going on in the system. Thus the RT class needs to be used with some care, as it can starve other processes. As with the best effort class, 8 priority levels are defined denoting how big a time slice a given process will receive on each scheduling window.  This scheduling class is given higher priority than any other in the system, processes from this class are given first access to the disk every time. Thus it needs to be used with some care, one io RT process can starve the entire system. Within the RT class, there are 8 levels of class data that determine exactly how much time this process needs the disk for on each service. In the future this might change to be more directly mappable to performance, by passing in a wanted data rate instead.</dd>
<dt><code>IOPRIO_CLASS_BE</code></dt>
<dd>This is the best-effort scheduling class, which is the default for any process that hasn&#8217;t set a specific io priority. This is the default scheduling class for any process that hasn&#8217;t asked for a specific io priority. Programs inherit the CPU nice setting for io priorities. This class takes a priority argument from 0-7, with lower number being higher priority. Programs running at the same best effort priority are served in a round-robin fashion.  The class data determines how much io bandwidth the process will get, it&#8217;s directly mappable to the cpu nice levels just more coarsely implemented. 0 is the highest BE prio level, 7 is the lowest. The mapping between cpu nice level and io nice level is determined as: io_nice = (cpu_nice + 20) / 5.</dd>
<dt><code>IOPRIO_CLASS_IDLE</code></dt>
<dd>This is the idle scheduling class, processes running at this level only get io time when no one else needs the disk. A program running with idle io priority will only get disk time when no other program has asked for disk io for a defined grace period. The impact of idle io processes on normal system activity should be zero. This scheduling class does not take a priority argument.    The idle class has no class data, since it doesn&#8217;t really apply here.</dd>
</dl>
<p><a id="ionice-tool" name="ionice-tool"></a></p>
<h3>ionice</h3>
<p>ionice &#8211; get/set program io scheduling class and priority.  This program sets the io scheduling class and priority for a program.  Since v3 (aka CFQ Time Sliced) CFQ implements I/O nice levels similar to those of CPU scheduling. These nice levels are grouped in three scheduling classes each one containing one or more priority levels:</p>
<p><a id="ionice-usage" name="ionice-usage"></a></p>
<h4>ionice usage</h4>
<p>If no arguments or just -p is given, ionice will query the current io scheduling class and priority for that process.</p>
<pre>ionice [-c] [-n] [-p] [COMMAND [ARG&#46;..]]</pre>
<ul>
<li><strong>-c</strong> &#8211; The scheduling class. 1 for real time, 2 for best-effort, 3 for idle.</li>
<li><strong>-n</strong> &#8211; The scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.</li>
<li><strong>-p</strong> &#8211; Pass in a process pid to change an already running process. If this argument is not given, ionice will run the listed program with the given parameters.</li>
</ul>
<p><a id="ionice-examples" name="ionice-examples"></a></p>
<h4>ionice Examples</h4>
<p>Sets process with PID 89 as an idle io process.</p>
<pre>ionice -c3 -p89</pre>
<p>Runs &#8216;bash&#8217; as a best-effort program with highest priority.</p>
<pre>ionice -c2 -n0 bash</pre>
<p>Returns the class and priority of the process with PID 89</p>
<pre>ionice -p89</pre>
<blockquote cite="http://gaarai.com/2009/03/06/multitasking-from-the-linux-command-line-plus-process-prioritization/">
<p>
<p>With the ionice command, you can set the IO priority for a process to one of three classes: Idle (3), Best Effort (2), and Real Time (1). The Idle class means that the process will only be able to read and write to the disk when all other processes are not using the disk. The Best Effort class is the default and has eight different priority levels from 0 (top priority) to 7 (lowest priority). The Real Time class results in the process having first access to the disk irregardless of other process and should never be used unless you know what you are doing.</p>
<p>If we wish to run the updatedb process in the background with an Idle IO class priority, we can run the following:</p>
<pre>$ sudo date
$ sudo updatedb &amp;
[1] 16324
$ sudo ionice -c3 -p16324</pre>
<p>If we’d rather just lower the Best Effort class priority (defaults to 4) for the command so the process isn’t limited to idle IO periods, we can run the following:</p>
<pre>$ sudo date
$ sudo updatedb &amp;
[1] 16324
$ sudo ionice -c2 -n7 -p16324</pre>
<p>Again, the Real Time class should not be used as it can prevent you from being able to interact with your system.</p>
<p>You may wonder where you can get the process ID if you don’t know it, can’t remember it, or didn’t start the process (an automatted script may have launched it). You can find process IDs with the ps command.</p>
<p>For example, if I had an updatedb program running in the background, and I wanted to find its process ID, I can run the following:</p>
<pre>$ ps -C updatedb
PID TTY TIME CMD
4234 ? 00:00:42 updatedb</pre>
<p>This tells me that the process’ process ID (PID) is 4234.</p>
</p>
</blockquote>
<p><a id="iostat-tool" name="iostat-tool"></a></p>
<h3>iostat</h3>
<p><a id="iostat-usage" name="iostat-usage"></a></p>
<h4>iostat Usage</h4>
<pre>iostat [ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [ &lt;device&gt; [&#46;..] | ALL ] [ -p [ &lt;device&gt; [,&#46;..] | ALL ] ] [ &lt;interval&gt; [ &lt;count&gt; ] ]

-c     The -c option is exclusive of the -d option and displays only the CPU usage report.
-d     The -d option is exclusive of the -c option and displays only the device utilization report.
-k     Display statistics in kilobytes per second instead of blocks per second.  Data displayed are valid only with kernels 2.4 and newer.
-m     Display statistics in megabytes per second instead of blocks or kilobytes per second.  Data displayed are valid only with kernels 2.4 and newer.
-n     Displays the NFS-directory statistic.  Data displayed are valid only with kernels 2.6.17 and newer.  This option is exclusive ot the -x option.
-h     Display the NFS report more human readable.
-p [ { device | ALL } ]   The  -p  option  is  exclusive  of  the -x option and displays statistics for block devices and all their partitions that are used by the system.
-t     Print the time for each report displayed.
-x     Display extended statistics.  </pre>
<p><a id="iostat-examples" name="iostat-examples"></a></p>
<h4>iostat Examples</h4>
<pre>iostat -p ALL 2 1000
avg-cpu:  %user   %nice    %sys %iowait   %idle
            8.34    0.08    1.26    2.27   88.05</pre>
<p>Display a single history since boot report for all CPU and Devices.</p>
<pre>$ iostat</pre>
<p>Display a continuous device report at two second intervals.</p>
<pre>$ iostat -d 2</pre>
<p>Display six reports at two second intervals for all devices.</p>
<pre>$ iostat -d 2 6</pre>
<p>Display six reports of extended statistics at two second intervals for devices hda and hdb.</p>
<pre>$ iostat -x hda hdb 2 6</pre>
<p>Display six reports at two second intervals for device sda and all its partitions (sda1, etc.)</p>
<pre>$ iostat -p sda 2 6</pre>
<p><a id="schedule-utils" name="schedule-utils"></a></p>
<h2>Schedule Utils</h2>
<p>These are the Linux scheduler utilities &#8211; schedutils for short.  These programs take advantage of the scheduler family of syscalls that Linux implements across various kernels.  These system calls implement interfaces for scheduler-related parameters such as CPU affinity and real-time attributes.  The standard UNIX utilities do not provide support for these interfaces &#8212; thus this package.</p>
<p>The programs that are included in this package are chrt and taskset.  Together with nice and renice (not included), they allow full control of process scheduling parameters.  Suggestions for related utilities are welcome, although it is believed (barring new interfaces) that all scheduling interfaces are covered.</p>
<p>I&#8217;ve found that quite a few servers do not have this package installed, indicating to you that they might not know what they are doing.  Here is how you can install this incredible package, for non-root users.  Root users know how to do this, or they shouldn&#8217;t be root.  Download and install in 1 line provided you have curl.  Or just use the following commands.</p>
<pre>mkdir -pv $HOME/{dist,source,bin,share/man/man1} &amp;&amp; cd ~/dist &amp;&amp; curl -O http://ftp.de.debian.org/debian/pool/main/s/schedutils/schedutils_1.5.0.orig.tar.gz &amp;&amp; cd ~/source &amp;&amp; tar -xvzf ~/dist/sch*z &amp;&amp; cd sch* &amp;&amp; sed -i -e &#039;s,= /usr/local,=${HOME},g&#039; Makefile &amp;&amp; make &amp;&amp; make install &amp;&amp; make installdoc</pre>
<pre>mkdir -pv $HOME/{dist,source,bin,share/man/man1}
cd ~/dist &amp;&amp; curl -O http://ftp.de.debian.org/debian/pool/main/s/schedutils/schedutils_1.5.0.orig.tar.gz
cd ~/source &amp;&amp; tar -xvzf ~/dist/schedutils_1.5.0.orig.tar.gz
cd ~/source/schedutils-1.5.0 &amp;&amp; sed -i -e &#039;s,= /usr/local,=${HOME},g&#039; Makefile
make || make -d &amp;&amp; make install || make install -d &amp;&amp; make installdoc || make installdoc -d</pre>
<p><a id="taskset-tool" name="taskset-tool"></a></p>
<h3>taskset</h3>
<p>Taskset  is  used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity.  CPU affinity is a scheduler property that &#8220;bonds&#8221; a process to a given set of CPUs on the system.  The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs.  Note that the Linux scheduler also supports natural CPU affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons.  Therefore, forcing a specific CPU affinity is useful only in certain applications.</p>
<p>The  CPU  affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU.  Not all CPUs may exist on a given system but a mask may specify more CPUs than are present.  A retrieved mask will reflect only the bits that correspond to CPUs physically on the system.  If an invalid mask is given (i.e., one that corresponds to no valid CPUs on the current system) an error is returned.  A user must possess CAP_SYS_NICE to change the CPU affinity of a process.  Any user can retrieve the affinity mask.</p>
<p><a id="taskset-usage" name="taskset-usage"></a></p>
<h4>taskset Usage</h4>
<pre>taskset [options] [mask | cpu-list] [pid | cmd [args&#46;..]]
&nbsp;
-p, &#45;-pid            operate on existing given pid
-c, &#45;-cpu-list     display and specify cpus in list format</pre>
<p><a id="taskset-examples" name="taskset-examples"></a></p>
<h4>taskset-examples</h4>
<p>The default behavior is to run a new command:</p>
<pre>$ taskset 03 sshd -b 1024</pre>
<p>You can retrieve the mask of an existing task or set it:</p>
<pre>$ taskset -p 700
$ taskset -p 03 700</pre>
<p>List format uses a comma-separated list instead of a mask:</p>
<pre>$ taskset -pc 0,3,7-11 700</pre>
<p><a id="chrt-tool" name="chrt-tool"></a></p>
<h3>chrt</h3>
<p><code>chrt</code> sets or retrieves the real-time scheduling attributes of an existing PID or runs COMMAND with the given attributes.  Both policy (one of <code>SCHED_FIFO</code>, <code>SCHED_RR</code>, or <code>SCHED_OTHER</code>) and priority can be set and retrieved.  A user must possess CAP_SYS_NICE to change the scheduling attributes of a process.  Any user can retrieve the scheduling information.</p>
<p><a id="chrt-usage" name="chrt-usage"></a></p>
<h4>chrt Usage</h4>
<pre>chrt [options] [prio] [pid | cmd [args&#46;..]]
&nbsp;
-p, &#45;-pid operate on an existing PID and do not launch a new task
-f, &#45;-fifo set scheduling policy to SCHED_FIFO
-m, &#45;-max show minimum and maximum valid priorities, then exit
-o, &#45;-other set policy scheduling policy to SCHED_OTHER
-r, &#45;-rr set scheduling policy to SCHED_RR (the default)</pre>
<p><a id="chrt-examples" name="chrt-examples"></a></p>
<h4>chrt Examples</h4>
<p>The default behavior is to run a new command:   <code>chrt [prio] -- [command] [arguments]</code></p>
<p>You can also retrieve the real-time attributes of an existing task:</p>
<pre>chrt -p [pid]</pre>
<p>Or set them:</p>
<pre>chrt -p [prio] [pid]</pre>
<p><a id="ulimit-tool" name="ulimit-tool"></a></p>
<h2>ulimit &#8211; get and set user limits</h2>
<p>Ulimit provides control over the resources available to processes started by the shell, on systems that allow such control. One can set the resource limits of the shell using the built-in ulimit command.  The shell&#8217;s resource limits are inherited by the processes that it creates to execute commands.</p>
<p><a id="ulimit-usage" name="ulimit-usage"></a></p>
<h4>ulimit Usage</h4>
<pre>ulimit [-SHacdfilmnpqstuvx] [limit]</pre>
<dl>
<dt>-S</dt>
<dd>use the `soft&#8217; resource limit</dd>
<dt>-H</dt>
<dd>use the `hard&#8217; resource limit</dd>
<dt>-a</dt>
<dd>all current limits are reported</dd>
<dt>-c</dt>
<dd>the maximum size of core files created</dd>
<dt>-d</dt>
<dd>the maximum size of a process&#8217;s data segment</dd>
<dt>-f</dt>
<dd>the maximum size of files created by the shell</dd>
<dt>-l</dt>
<dd>the maximum size a process may lock into memory</dd>
<dt>-m</dt>
<dd>the maximum resident set size</dd>
<dt>-n</dt>
<dd>the maximum number of open file descriptors</dd>
<dt>-p</dt>
<dd>the pipe buffer size</dd>
<dt>-s</dt>
<dd>the maximum stack size</dd>
<dt>-t</dt>
<dd>the maximum amount of cpu time in seconds</dd>
<dt>-u</dt>
<dd>the maximum number of user processes</dd>
<dt>-v</dt>
<dd>the size of virtual memory</dd>
</dl>
<p>If LIMIT is given, it is the new value of the specified resource; the special LIMIT values `soft&#8217;, `hard&#8217;, and `unlimited&#8217; stand for the current soft limit, the current hard limit, and no limit, respectively.  Otherwise, the current value of the specified resource is printed.  If no option is given, then -f is assumed.  Values are in 1024-byte increments, except for -t, which is in seconds, -p, which is in increments of 512 bytes, and -u, which is an unscaled number of processes.</p>
<dl>
<dt>RLIMIT_AS</dt>
<dd>The maximum size of the process&#8217;s virtual memory (address space) in bytes.  This limit affects calls to brk(2), mmap(2) and mremap(2), which fail with the error ENOMEM upon exceeding this limit.  Also automatic stack expansion will fail (and generate a SIGSEGV that kills the process if no alternate stack has been made available via sigaltstack(2)).  Since the value is a long, on machines with a 32-bit long either this limit is at most 2 GiB, or this resource is unlimited.</dd>
<dt>RLIMIT_CORE</dt>
<dd>Maximum size of core file.  When 0 no core dump files are created. When non-zero, larger dumps are truncated to this size.</dd>
<dt>RLIMIT_CPU CPU</dt>
<dd>time limit in seconds.  When the process reaches the soft limit, it is sent a SIGXCPU signal.  The default action for this signal is to terminate the process.  However, the signal can be caught, and the handler can return control to the main program.  If the process continues to consume CPU time, it will be sent SIGXCPU once per second until the hard limit is reached, at which time it is sent SIGKILL. (This latter point describes Linux 2.2 through 2.6 behavior. Implementations vary in how they treat processes which continue to consume CPU time after reaching the soft limit.  Portable applications that need to catch this signal should perform an orderly termination upon first receipt of SIGXCPU.)</dd>
<dt>RLIMIT_DATA</dt>
<dd>The maximum size of the process&#8217;s data segment (initialized data, uninitialized data, and heap).  This limit affects calls to brk(2) and sbrk(2), which fail with the error ENOMEM upon encountering the soft limit of this resource.</dd>
<dt>RLIMIT_FSIZE</dt>
<dd>The maximum size of files that the process may create.  Attempts to extend a file beyond this limit result in delivery of a SIGXFSZ signal. By default, this signal terminates a process, but a process can catch this signal instead, in which case the relevant system call (e.g., write(2), truncate(2)) fails with the error EFBIG.</dd>
<dt>RLIMIT_LOCKS</dt>
<dd>(Early Linux 2.4 only) A limit on the combined number of flock(2) locks and fcntl(2) leases that this process may establish.</dd>
<dt>RLIMIT_MEMLOCK</dt>
<dd>The maximum number of bytes of memory that may be locked into RAM.  In effect this limit is rounded down to the nearest multiple of the system page size.  This limit affects mlock(2) and mlockall(2) and the mmap(2) MAP_LOCKED operation.  Since Linux 2.6.9 it also affects the shmctl(2) SHM_LOCK operation, where it sets a maximum on the total bytes in shared memory segments (see shmget(2)) that may be locked by the real user ID of the calling process.  The shmctl(2) SHM_LOCK locks are accounted for separately from the per-process memory locks established by mlock(2), mlockall(2), and mmap(2) MAP_LOCKED; a process can lock bytes up to this limit in each of these two categories.  In Linux kernels before 2.6.9, this limit controlled the amount of memory that could be locked by a privileged process.  Since Linux 2.6.9, no limits are placed on the amount of memory that a privileged process may lock, and this limit instead governs the amount of memory that an unprivileged process may lock.</dd>
<dt>RLIMIT_MSGQUEUE</dt>
<dd>(Since Linux 2.6.8) Specifies the limit on the number of bytes that can be allocated for POSIX message queues for the real user ID of the calling process.  This limit is enforced for mq_open(3).  Each message queue that the user creates counts (until it is removed) against this limit according to the formula:  <code>bytes = attr.mq_maxmsg * sizeof(struct msg_msg *) +             attr.mq_maxmsg * attr.mq_msgsize</code> where attr is the mq_attr structure specified as the fourth argument to mq_open(3).  The first addend in the formula, which includes sizeof(struct msg_msg *) (4 bytes on Linux/i386), ensures that the user cannot create an unlimited number of zero-length messages (such messages nevertheless each consume some system memory for bookkeeping overhead).</dd>
<dt>RLIMIT_NICE</dt>
<dd>(since Linux 2.6.12, but see BUGS below) Specifies a ceiling to which the process&#8217;s nice value can be raised using setpriority(2) or nice(2).  The actual ceiling for the nice value is calculated as 20 &#8211; rlim_cur.  (This strangeness occurs because negative numbers cannot be specified as resource limit values, since they typically have special meanings.  For example, RLIM_INFINITY typically is the same as -1.)</dd>
<dt>RLIMIT_NOFILE</dt>
<dd>Specifies a value one greater than the maximum file descriptor number that can be opened by this process.  Attempts (open(2), pipe(2), dup(2), etc.)  to exceed this limit yield the error EMFILE. (Historically, this limit was named RLIMIT_OFILE on BSD.)</dd>
<dt>RLIMIT_NPROC</dt>
<dd>The maximum number of processes (or, more precisely on Linux, threads) that can be created for the real user ID of the calling process.  Upon encountering this limit, fork(2) fails with the error EAGAIN.</dd>
<dt>RLIMIT_RSS</dt>
<dd>Specifies the limit (in pages) of the process&#8217;s resident set (the number of virtual pages resident in RAM).  This limit only has effect in Linux 2.4.x, x < 30, and there only affects calls to madvise(2) specifying MADV_WILLNEED.</dd>
<dt>RLIMIT_RTPRIO</dt>
<dd>(Since Linux 2.6.12, but see BUGS) Specifies a ceiling on the real-time priority that may be set for this process using sched_setscheduler(2) and sched_setparam(2).</dd>
<dt>RLIMIT_RTTIME</dt>
<dd>(Since Linux 2.6.25) Specifies a limit on the amount of CPU time that a process scheduled under a real-time scheduling policy may consume without making a blocking system call.  For the purpose of this limit, each time a process makes a blocking system call, the count of its consumed CPU time is reset to zero.  The CPU time count is not reset if the process continues trying to use the CPU but is preempted, its time slice expires, or it calls sched_yield(2). Upon reaching the soft limit, the process is sent a SIGXCPU signal.  If the process catches or ignores this signal and continues consuming CPU time, then SIGXCPU will be generated once each second until the hard limit is reached, at which point the process is sent a SIGKILL signal.  The intended use of this limit is to stop a runaway real-time process from locking up the system.</dd>
<dt>RLIMIT_SIGPENDING</dt>
<dd>(Since Linux 2.6.8) Specifies the limit on the number of signals that may be queued for the real user ID of the calling process.  Both standard and real-time signals are counted for the purpose of checking this limit.  However, the limit is only enforced for sigqueue(2); it is always possible to use kill(2) to queue one instance of any of the signals that are not already queued to the process.</dd>
<dt>RLIMIT_STACK</dt>
<dd>The maximum size of the process stack, in bytes.  Upon reaching this limit, a SIGSEGV signal is generated.  To handle this signal, a process must employ an alternate signal stack (sigaltstack(2)).</dd>
</dl>
<p><a id="ulimit-examples" name="ulimit-examples"></a></p>
<h4>ulimit Examples</h4>
<p>Turn off core dumps</p>
<pre>ulimit -S -c 0</pre>
<h2>More Reading</h2>
<ul>
<li>Please see the <a href="http://pagesperso-orange.fr/sebastien.godard/" rel="nofollow" >SYSSTAT Utilities Home for more performance monitoring tools</a> like sar, sadf, mpstat, iostat, pidstat and sa tools.</li>
<li><a href="http://gaarai.com/2009/03/06/multitasking-from-the-linux-command-line-plus-process-prioritization/" rel="nofollow" >Multitasking from the Linux Command Line + Process Prioritization</a></li>
</ul>
<h2>Man Pages</h2>
<ol>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man2/sched_setscheduler.2.html" rel="nofollow" >sched_setscheduler</a></li>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man7/cpuset.7.html" rel="nofollow" >cpuset</a></li>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man7/signal.7.html" rel="nofollow" >signal</a></li>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man2/getrlimit.2.html" rel="nofollow" >getrlimit</a></li>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man3/ulimit.3.html" rel="nofollow" >ulimit</a></li>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man2/ioprio_get.2.html" rel="nofollow" >ioprio_get</a></li>
<li><a href="http://www.kernel.org/doc/man-pages/online/pages/man2/ioprio_set.2.html" rel="nofollow" >ioprio_set</a></li>
</ol>
<h2>Kernel Documentation</h2>
<ul>
<li><a href='http://uploads.askapache.com/2009/08/sched-stats.txt'>information on schedstats (Linux Scheduler Statistics)</a></li>
<li><a href='http://uploads.askapache.com/2009/08/sched-rt-group.txt'>real-time group scheduling</a></li>
<li><a href='http://uploads.askapache.com/2009/08/sched-nice-design.txt'>How and why the scheduler&#8217;s nice levels are implemented</a></li>
<li><a href='http://uploads.askapache.com/2009/08/sched-domains.txt'>information on scheduling domains</a></li>
<li><a href='http://uploads.askapache.com/2009/08/sched-design-CFS.txt'>goals, design and implementation of the Complete Fair Scheduler</a></li>
</ul>
<h2>Future Discussions:</h2>
<p><a href="http://www.cuddletech.com/blog/pivot/entry.php?id=820" rel="nofollow" >IO Benchmarking: How, Why and With What</a></p>
<p><a href="http://www.askapache.com/linux-unix/optimize-nice-ionice.html"></a><a href="http://www.askapache.com/linux-unix/optimize-nice-ionice.html">Optimizing Servers and Processes for Speed with ionice, nice, ulimit</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux-unix/optimize-nice-ionice.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Protecting Files with Advanced Mod_Rewrite Anti-Hotlinking</title>
		<link>http://www.askapache.com/htaccess/anti-hotlinking-mod_rewrite.html</link>
		<comments>http://www.askapache.com/htaccess/anti-hotlinking-mod_rewrite.html#comments</comments>
		<pubDate>Wed, 16 Sep 2009 05:09:11 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Blocking]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[hotlinking]]></category>
		<category><![CDATA[htaccess tutorial]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3287</guid>
		<description><![CDATA[<p><a class="IFL" id="id17" href="http://www.askapache.com/htaccess/anti-hotlinking-mod_rewrite.html"></a>If you have files on your site that you don't want indexed by malicious search engines, grabbed and leeched by malicious spammers, or stolen and made available elsewhere, you can use mod_rewrite to drastically reduce or totally reduce that activity.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://uploads.askapache.com/2009/09/866310_predestrian_lights.jpg" rel="nofollow" class="IFL" id="id17" ></a><br style="padding-top:2em;" /><br />If you have files on your site that you don&#8217;t want indexed by malicious search engines, grabbed and leeched by malicious spammers, or stolen and made available elsewhere, you can use mod_rewrite to drastically reduce or totally reduce that activity.</p>
<h2>The Worst Kind of People</h2>
<p><strong>Spammers, and Leechers</strong>.  They operate like this:  Let&#8217;s say you have some mp3 files on a server, and SOMEWHERE on the web there is a link to that mp3 file&#8217;s location.  This includes in javascript files, css files, robots.txt files, the spammers and leechers robots check all those files looking for the type of link they are looking for.   Then they try to request that file usually utilizing a number of different types of requests to get access to the file.  Then they use it for personal gain, at your peril.</p>
<p>Some robots perform valuable services for the world wide web community, and other leeching programming is pretty cool, so not all these activities are perpetrated by nefarious spammers.</p>
<p><br class="C" /></p>
<h2>Blocking by IP COOKIE</h2>
<p>Ok so if a link exists to your file, it is going to be requested by a robot eventually, so the way to defeat them is by doing something on your site that modifies the way a user would request it.  Robots for the most part are not javascript-capable, so the most-common advanced method is to set a cookie using javascript, and then we can check for that cookie in the request for the file using mod_rewrite.</p>
<p>So if your site sets a cookie named fspammers, and furthermore gives that cookie a value of 445, then this is what the request sent by an HTTP Client like Firefox looks like.</p>
<pre>GET /hotlink/lovefreedom.mp3 HTTP/1.1
Host: static.askapache.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.askapache.com/wordpress/seo-in-wordpress.html
Cookie: fspammers=455</pre>
<h2>Mod_Rewrite HTTP Headers</h2>
<p>The mod_rewrite module has access to ALL the HTTP Headers sent in a request, so for each of the HTTP Headers in the request example above, we can use mod_rewrite to validate.</p>
<h2>Mod_Rewrite .htaccess Example</h2>
<p>Finally, now that everyone is on the same page about what is really going on, here is the <a href="http://www.askapache.com/htaccess/htaccess.html" title=".htaccess tutorial">.htaccess</a> code that blocks any requests for anything in the /hotlink/ folder.</p>
<p>Here are the triggers this code blocks access based on.</p>
<ol>
<li><strong>Cookie</strong>: Checks if fspammers cookie is present, and that it has the value of 445. </li>
<li><strong>HTTP Protocol</strong>: Checks if HTTP 1.1 is being used (many robots use 1.0)</li>
<li><strong>Host</strong>: Checks that the HOST Requested was static.askapache.com</li>
<li><strong>Referer</strong>:  Checks for Referring site is static.askapache.com or www.askapache.com</li>
</ol>
<pre>RewriteEngine On
RewriteBase /
&nbsp;
RewriteCond %{HTTP_COOKIE} !^.*fspammers=445.*$ [NC,OR]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /(.*)\ HTTP/1\.1 [NC,OR]
RewriteCond %{HTTP_HOST} !^z\.askapache\.com$ [NC,OR]
RewriteCond %{HTTP_REFERER} !^http://(www|z)\.askapache\.com.*$ [NC]
RewriteRule ^hotlink/.*$ - [F]&lt;/p&gt;</pre>
<p><a href="http://www.askapache.com/htaccess/anti-hotlinking-mod_rewrite.html"></a><a href="http://www.askapache.com/htaccess/anti-hotlinking-mod_rewrite.html">Protecting Files with Advanced Mod_Rewrite Anti-Hotlinking</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/anti-hotlinking-mod_rewrite.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crazy Advanced Mod_Rewrite Tutorial</title>
		<link>http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html</link>
		<comments>http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:55:32 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[FeedBurner]]></category>
		<category><![CDATA[FeedCount]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[htaccess rewrite]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[HTTP Status Codes]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[Mod_Security]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Redirection]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[SetEnvIf]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=1209</guid>
		<description><![CDATA[<p><strong>Note:  Extremely ILL Content</strong><br />Find the key to unlocking mod_rewrite and you WILL be sick..  sick with a diamond disease on your wrist!<br /><a class="hs hs13" href="http://uploads.askapache.com/2008/08/mod_rewrite_ascii.png"></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://uploads.askapache.com/2008/08/mod_rewrite_ascii.png" rel="nofollow" class="hs hs13" ></a><strong>Are you an advanced mod_rewrite expert or guru?</strong>  This article is for YOU too!  Just make sure to read all the way to the bottom..<br class="C" /></p>
<p class="anote">The following undocumented techniques and methods will allow you to utilize mod_rewrite at an  &#8220;expert level&#8221; by showing you how to <a href="http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html#decoded">unlock its secrets</a>.  <br class="C" /></p>
<p>Most if not all web developers and server administrators struggle with Apache mod_rewrite.  It&#8217;s very tough and only gets a little easier with practice.  Until Now!  Get ready to explode your learning curve, I figured something out.</p>
<h2>Why mod_rewrite is so tough</h2>
<p>I have come to the conclusion, after many hours of zenful thought, that the reason mod_rewrite is so tough is pretty obvious, people are trying to apply regular-expressions to URLs and Variables that they don&#8217;t really understand.  They understand what they want, but they don&#8217;t understand what the URLS and Variables are that they are trying to rewrite.</p>
<h2>Hit-Or-Miss with mod_rewrite</h2>
<p>A lot of the mod_rewrite &#8220;experts&#8221; and &#8220;gurus&#8221; floating around the net absolutely know their mod_rewrite, but what separates them from a beginner or novice is for the most part an understanding of what the URLS and Variables look like that are targeted by the regular expressions.  Take this simple rewriterule that rewrites requests made without the www to www.</p>
<pre>RewriteEngine On
RewriteBase /
&nbsp;
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule .+ http://www.askapache.com%{REQUEST_URI}</pre>
<p>Pretty simple right?  WRONG.  Most people could not figure that out..</p>
<h3>Why?</h3>
<p>The reason intelligent people can&#8217;t figure that out is because they have no idea what HTTP_HOST or REQUEST_URI actually looks like.  How can you write a rule for something if you don&#8217;t know what it looks like?  You can&#8217;t.</p>
<h2>When Not To Use Mod_Rewrite</h2>
<p>Ok so heres an important concept that alot of people haven&#8217;t heard.  You should only use <a href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html">mod_rewrite&#8217;s rewriterule </a>when you use a rewritecond or if you are rewriting internally like my <a href="http://www.askapache.com/htaccess/pimp-out-your-feedburner-count.html">feedcount hack</a>.</p>
<p>If you are simply redirecting one url to another, you should definately be using the much easier <a href="http://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html">mod_alias&#8217;s redirect and redirectmatch</a>, which is enabled on most Apache servers.</p>
<h2>When To Use Mod_Rewrite</h2>
<p>So then, you should only use mod_rewrite&#8217;s rewriterule when you are checking against one of the Apache Environment Variables to determine whether to rewrite or not.  This is where the Apache Documentation is grossly lacking.  They don&#8217;t tell you what those variables look like, leaving us completely incapable of creating rewrites based on them.  <strong>Not anymore.</strong></p>
<h3>Mod_Rewrite Environment Variables (The Secret)</h3>
<p>Here&#8217;s the variables I have found accessible by <a href="http://httpd.apache.org/docs/trunk/mod/mod_rewrite.html#rewritecond" rel="nofollow" >mod_rewrite</a> (both documented and undocumented).   A thing to note is that you can set these variables early in an .htaccess file using SetEnv, RewriteRule, Header, etc.. and they will be accessible at the end of the .htaccess file.<br class="C" /></p>
<ul class="UL1">
<li><code>API_VERSION</code></li>
<li><code>AUTH_TYPE</code></li>
<li><code>CONTENT_LENGTH</code></li>
<li><code>CONTENT_TYPE</code></li>
<li><code>DOCUMENT_ROOT</code></li>
<li><code>GATEWAY_INTERFACE</code></li>
<li><code>HTTPS</code></li>
<li><code>HTTP_ACCEPT</code></li>
<li><code>HTTP_ACCEPT_CHARSET</code></li>
<li><code>HTTP_ACCEPT_ENCODING</code></li>
<li><code>HTTP_ACCEPT_LANGUAGE</code></li>
<li><code>HTTP_CACHE_CONTROL</code></li>
</ul>
<ul class="UL1">
<li><code>HTTP_CONNECTION</code></li>
<li><code>HTTP_COOKIE</code></li>
<li><code>HTTP_FORWARDED</code></li>
<li><code>HTTP_HOST</code></li>
<li><code>HTTP_KEEP_ALIVE</code></li>
<li><code>HTTP_PROXY_CONNECTION</code></li>
<li><code>HTTP_REFERER</code></li>
<li><code>HTTP_USER_AGENT</code></li>
<li><code>IS_SUBREQ</code></li>
<li><code>ORIG_PATH_INFO</code></li>
<li><code>ORIG_PATH_TRANSLATED</code></li>
<li><code>ORIG_SCRIPT_FILENAME</code></li>
</ul>
<ul class="UL1">
<li><code>ORIG_SCRIPT_NAME</code></li>
<li><code>PATH</code></li>
<li><code>PATH_INFO</code></li>
<li><code>PHP_SELF</code></li>
<li><code>QUERY_STRING</code></li>
<li><code>REDIRECT_QUERY_STRING</code></li>
<li><code>REDIRECT_REMOTE_USER</code></li>
<li><code>REDIRECT_STATUS</code></li>
<li><code>REDIRECT_URL</code></li>
<li><code>REMOTE_ADDR</code></li>
<li><code>REMOTE_HOST</code></li>
<li><code>REMOTE_IDENT</code></li>
</ul>
<ul class="UL1">
<li><code>REMOTE_PORT</code></li>
<li><code>REMOTE_USER</code></li>
<li><code>REQUEST_FILENAME</code></li>
<li><code>REQUEST_METHOD</code></li>
<li><code>REQUEST_TIME</code></li>
<li><code>REQUEST_URI</code></li>
<li><code>SCRIPT_FILENAME</code></li>
<li><code>SCRIPT_GROUP</code></li>
<li><code>SCRIPT_NAME</code></li>
<li><code>SCRIPT_URI</code></li>
<li><code>SCRIPT_URL</code></li>
<li><code>SCRIPT_USER</code></li>
</ul>
<ul class="UL1">
<li><code>SERVER_ADDR</code></li>
<li><code>SERVER_ADMIN</code></li>
<li><code>SERVER_NAME</code></li>
<li><code>SERVER_PORT</code></li>
<li><code>SERVER_PROTOCOL</code></li>
<li><code>SERVER_SIGNATURE</code></li>
<li><code>SERVER_SOFTWARE</code></li>
<li><code>THE_REQUEST</code></li>
<li><code>TIME</code></li>
<li><code>TIME_DAY</code></li>
<li><code>TIME_HOUR</code></li>
<li><code>TIME_MIN</code></li>
</ul>
<ul class="UL1">
<li><code>TIME_MON</code></li>
<li><code>TIME_SEC</code></li>
<li><code>TIME_WDAY</code></li>
<li><code>TIME_YEAR</code></li>
<li><code>TZ</code></li>
<li><code>UNIQUE_ID</code></li>
</ul>
<hr class="C" />
<h2>Decoding Mod_Rewrite Variables</h2>
<p>So when I realized my problem was that I didn&#8217;t know the value of the variable being tested by the RewriteCond, I set out to try and discover how to view those variables..  Keep in mind you can also use RewriteLogging, but its only allowed for root users who can edit the httpd.conf, this is .htaccess.</p>
<h3>Setting Environment Variables with RewriteRule</h3>
<p>I discovered a multitude of methods to set and view apache environment variables, using various modules and some core tricks, but the method that allows me to view the most environment variables is RewriteRule.. I wanted to use <a href="http://www.askapache.com/htaccess/setenvif.html">SetEnvIf</a> more, but its just not as powerful as mod_rewrite, due to programming.</p>
<p>This code sets the variable <code>INFO_REQUEST_URI</code> to have the value of <code>REQUEST_URI</code>.</p>
<pre>RewriteEngine On
RewriteBase /
RewriteRule .* - [E=INFO_REQUEST_URI:%{REQUEST_URI},NE]</pre>
<h3>Saving the Apache Variable Values</h3>
<p>Now the trick is how to view that environment variable&#8230;  The method I came up with is nice&#8230; We will send the environment variable value in an HTTP Header, as there isn&#8217;t much data manipulation/validation so you get an accurate look at the actual value..  At first I tried adding the variable value to a redirection using the query_string.. but a HTTP_USER_AGENT value doesn&#8217;t play well as a query_string.</p>
<h4>Using RequestHeader in .htaccess</h4>
<p>This code takes advantage of the incredible mod_headers apache module to actually ADD a whole new header to YOUR request.  Seriously one of the coolest tricks I&#8217;ve found yet.. Its almost the same as being able to spoof POST requests!  Since Headers can be protected data&#8230; <em>especially the HTTP_COOKIE header</em>..</p>
<pre>RequestHeader set INFO_REQUEST_URI &quot;%{INFO_REQUEST_URI}e&quot;</pre>
<h3>Viewing the Variable Values</h3>
<p>Now you can use any kind of server-run interpreter like perl, php, ruby, etc., to view all the variable values.  All cgi-script handlers like those are able to view request headers.. </p>
<h3>PHP Code to access Apache Variables</h3>
<p>Works even in safe-mode&#8230; any interpreter can view HTTP Headers!  Note that each of these variables are added as HTTP headers to the request for the script.. kinda confusing.. So each variable sent as a header is prefixed with HTTP_ to denote it was a header.</p>
<pre>&lt;?php
header(&quot;Content-Type: text/plain&quot;);
$INFO=$MISS=array();
foreach($_SERVER as $v=&gt;$r)
{
  if(substr($v,0,9)==&#039;HTTP_INFO&#039;)
  {
    if(!empty($r))$INFO[substr($v,10)]=$r;
    else $MISS[substr($v,10)]=$r;
  }
}
&nbsp;
/* thanks Mike! */
ksort($INFO);
ksort($MISS);
ksort($_SERVER);
&nbsp;
echo &quot;Received These Variables:\n&quot;;
print_r($INFO);
&nbsp;
echo &quot;Missed These Variables:\n&quot;;
print_r($MISS);
&nbsp;
echo &quot;ALL Variables:\n&quot;;
print_r($_SERVER);
?&gt;</pre>
<h2>Time to Get Crazy</h2>
<p>Just create the above php file on your site as <code>/test/index.php</code> or whatever, then create /test/.htaccess which should contain the below <code>.htaccess file</code> snippet.  Now just request <code>/test/index.php</code> and be amazed!   If you&#8217;re looking for more general help check out this excellent <a href="http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/" rel="nofollow" >mod_rewrite cheat sheet</a>.</p>
<p>Ok, so I&#8217;ve prepared the .htaccess code you can use to view the values of all these variables.  Just add it to a .htaccess file and make a request.  For this test I created an index.php file that printed out all the <code>$_SERVER</code> variables, and made requests to it.</p>
<pre>RewriteEngine On
RewriteBase /
RewriteRule .* - [E=INFO_API_VERSION:%{API_VERSION},NE]
RewriteRule .* - [E=INFO_AUTH_TYPE:%{AUTH_TYPE},NE]
RewriteRule .* - [E=INFO_CONTENT_LENGTH:%{CONTENT_LENGTH},NE]
RewriteRule .* - [E=INFO_CONTENT_TYPE:%{CONTENT_TYPE},NE]
RewriteRule .* - [E=INFO_DOCUMENT_ROOT:%{DOCUMENT_ROOT},NE]
RewriteRule .* - [E=INFO_GATEWAY_INTERFACE:%{GATEWAY_INTERFACE},NE]
RewriteRule .* - [E=INFO_HTTPS:%{HTTPS},NE]
RewriteRule .* - [E=INFO_HTTP_ACCEPT:%{HTTP_ACCEPT},NE]
RewriteRule .* - [E=INFO_HTTP_ACCEPT_CHARSET:%{HTTP_ACCEPT_CHARSET},NE]
RewriteRule .* - [E=INFO_HTTP_ACCEPT_ENCODING:%{HTTP_ACCEPT_ENCODING},NE]
RewriteRule .* - [E=INFO_HTTP_ACCEPT_LANGUAGE:%{HTTP_ACCEPT_LANGUAGE},NE]
RewriteRule .* - [E=INFO_HTTP_CACHE_CONTROL:%{HTTP_CACHE_CONTROL},NE]
RewriteRule .* - [E=INFO_HTTP_CONNECTION:%{HTTP_CONNECTION},NE]
RewriteRule .* - [E=INFO_HTTP_COOKIE:%{HTTP_COOKIE},NE]
RewriteRule .* - [E=INFO_HTTP_FORWARDED:%{HTTP_FORWARDED},NE]
RewriteRule .* - [E=INFO_HTTP_HOST:%{HTTP_HOST},NE]
RewriteRule .* - [E=INFO_HTTP_KEEP_ALIVE:%{HTTP_KEEP_ALIVE},NE]
RewriteRule .* - [E=INFO_HTTP_MOD_SECURITY_MESSAGE:%{HTTP_MOD_SECURITY_MESSAGE},NE]
RewriteRule .* - [E=INFO_HTTP_PROXY_CONNECTION:%{HTTP_PROXY_CONNECTION},NE]
RewriteRule .* - [E=INFO_HTTP_REFERER:%{HTTP_REFERER},NE]
RewriteRule .* - [E=INFO_HTTP_USER_AGENT:%{HTTP_USER_AGENT},NE]
RewriteRule .* - [E=INFO_IS_SUBREQ:%{IS_SUBREQ},NE]
RewriteRule .* - [E=INFO_ORIG_PATH_INFO:%{ORIG_PATH_INFO},NE]
RewriteRule .* - [E=INFO_ORIG_PATH_TRANSLATED:%{ORIG_PATH_TRANSLATED},NE]
RewriteRule .* - [E=INFO_ORIG_SCRIPT_FILENAME:%{ORIG_SCRIPT_FILENAME},NE]
RewriteRule .* - [E=INFO_ORIG_SCRIPT_NAME:%{ORIG_SCRIPT_NAME},NE]
RewriteRule .* - [E=INFO_PATH:%{PATH},NE]
RewriteRule .* - [E=INFO_PATH_INFO:%{PATH_INFO},NE]
RewriteRule .* - [E=INFO_PHP_SELF:%{PHP_SELF},NE]
RewriteRule .* - [E=INFO_QUERY_STRING:%{QUERY_STRING},NE]
RewriteRule .* - [E=INFO_REDIRECT_QUERY_STRING:%{REDIRECT_QUERY_STRING},NE]
RewriteRule .* - [E=INFO_REDIRECT_REMOTE_USER:%{REDIRECT_REMOTE_USER},NE]
RewriteRule .* - [E=INFO_REDIRECT_STATUS:%{REDIRECT_STATUS},NE]
RewriteRule .* - [E=INFO_REDIRECT_URL:%{REDIRECT_URL},NE]
RewriteRule .* - [E=INFO_REMOTE_ADDR:%{REMOTE_ADDR},NE]
RewriteRule .* - [E=INFO_REMOTE_HOST:%{REMOTE_HOST},NE]
RewriteRule .* - [E=INFO_REMOTE_IDENT:%{REMOTE_IDENT},NE]
RewriteRule .* - [E=INFO_REMOTE_PORT:%{REMOTE_PORT},NE]
RewriteRule .* - [E=INFO_REMOTE_USER:%{REMOTE_USER},NE]
RewriteRule .* - [E=INFO_REQUEST_FILENAME:%{REQUEST_FILENAME},NE]
RewriteRule .* - [E=INFO_REQUEST_METHOD:%{REQUEST_METHOD},NE]
RewriteRule .* - [E=INFO_REQUEST_TIME:%{REQUEST_TIME},NE]
RewriteRule .* - [E=INFO_REQUEST_URI:%{REQUEST_URI},NE]
RewriteRule .* - [E=INFO_SCRIPT_FILENAME:%{SCRIPT_FILENAME},NE]
RewriteRule .* - [E=INFO_SCRIPT_GROUP:%{SCRIPT_GROUP},NE]
RewriteRule .* - [E=INFO_SCRIPT_NAME:%{SCRIPT_NAME},NE]
RewriteRule .* - [E=INFO_SCRIPT_URI:%{SCRIPT_URI},NE]
RewriteRule .* - [E=INFO_SCRIPT_URL:%{SCRIPT_URL},NE]
RewriteRule .* - [E=INFO_SCRIPT_USER:%{SCRIPT_USER},NE]
RewriteRule .* - [E=INFO_SERVER_ADDR:%{SERVER_ADDR},NE]
RewriteRule .* - [E=INFO_SERVER_ADMIN:%{SERVER_ADMIN},NE]
RewriteRule .* - [E=INFO_SERVER_NAME:%{SERVER_NAME},NE]
RewriteRule .* - [E=INFO_SERVER_PORT:%{SERVER_PORT},NE]
RewriteRule .* - [E=INFO_SERVER_PROTOCOL:%{SERVER_PROTOCOL},NE]
RewriteRule .* - [E=INFO_SERVER_SIGNATURE:%{SERVER_SIGNATURE},NE]
RewriteRule .* - [E=INFO_SERVER_SOFTWARE:%{SERVER_SOFTWARE},NE]
RewriteRule .* - [E=INFO_THE_REQUEST:%{THE_REQUEST},NE]
RewriteRule .* - [E=INFO_TIME:%{TIME},NE]
RewriteRule .* - [E=INFO_TIME_DAY:%{TIME_DAY},NE]
RewriteRule .* - [E=INFO_TIME_HOUR:%{TIME_HOUR},NE]
RewriteRule .* - [E=INFO_TIME_MIN:%{TIME_MIN},NE]
RewriteRule .* - [E=INFO_TIME_MON:%{TIME_MON},NE]
RewriteRule .* - [E=INFO_TIME_SEC:%{TIME_SEC},NE]
RewriteRule .* - [E=INFO_TIME_WDAY:%{TIME_WDAY},NE]
RewriteRule .* - [E=INFO_TIME_YEAR:%{TIME_YEAR},NE]
RewriteRule .* - [E=INFO_TZ:%{TZ},NE]
RewriteRule .* - [E=INFO_UNIQUE_ID:%{UNIQUE_ID},NE]
&nbsp;
RequestHeader set INFO_API_VERSION &quot;%{INFO_API_VERSION}e&quot;
RequestHeader set INFO_AUTH_TYPE &quot;%{INFO_AUTH_TYPE}e&quot;
RequestHeader set INFO_CONTENT_LENGTH &quot;%{INFO_CONTENT_LENGTH}e&quot;
RequestHeader set INFO_CONTENT_TYPE &quot;%{INFO_CONTENT_TYPE}e&quot;
RequestHeader set INFO_DOCUMENT_ROOT &quot;%{INFO_DOCUMENT_ROOT}e&quot;
RequestHeader set INFO_GATEWAY_INTERFACE &quot;%{INFO_GATEWAY_INTERFACE}e&quot;
RequestHeader set INFO_HTTPS &quot;%{INFO_HTTPS}e&quot;
RequestHeader set INFO_HTTP_ACCEPT &quot;%{INFO_HTTP_ACCEPT}e&quot;
RequestHeader set INFO_HTTP_ACCEPT_CHARSET &quot;%{INFO_HTTP_ACCEPT_CHARSET}e&quot;
RequestHeader set INFO_HTTP_ACCEPT_ENCODING &quot;%{INFO_HTTP_ACCEPT_ENCODING}e&quot;
RequestHeader set INFO_HTTP_ACCEPT_LANGUAGE &quot;%{INFO_HTTP_ACCEPT_LANGUAGE}e&quot;
RequestHeader set INFO_HTTP_CACHE_CONTROL &quot;%{INFO_HTTP_CACHE_CONTROL}e&quot;
RequestHeader set INFO_HTTP_CONNECTION &quot;%{INFO_HTTP_CONNECTION}e&quot;
RequestHeader set INFO_HTTP_COOKIE &quot;%{INFO_HTTP_COOKIE}e&quot;
RequestHeader set INFO_HTTP_FORWARDED &quot;%{INFO_HTTP_FORWARDED}e&quot;
RequestHeader set INFO_HTTP_HOST &quot;%{INFO_HTTP_HOST}e&quot;
RequestHeader set INFO_HTTP_KEEP_ALIVE &quot;%{INFO_HTTP_KEEP_ALIVE}e&quot;
RequestHeader set INFO_HTTP_MOD_SECURITY_MESSAGE &quot;%{INFO_HTTP_MOD_SECURITY_MESSAGE}e&quot;
RequestHeader set INFO_HTTP_PROXY_CONNECTION &quot;%{INFO_HTTP_PROXY_CONNECTION}e&quot;
RequestHeader set INFO_HTTP_REFERER &quot;%{INFO_HTTP_REFERER}e&quot;
RequestHeader set INFO_HTTP_USER_AGENT &quot;%{INFO_HTTP_USER_AGENT}e&quot;
RequestHeader set INFO_IS_SUBREQ &quot;%{INFO_IS_SUBREQ}e&quot;
RequestHeader set INFO_ORIG_PATH_INFO &quot;%{INFO_ORIG_PATH_INFO}e&quot;
RequestHeader set INFO_ORIG_PATH_TRANSLATED &quot;%{INFO_ORIG_PATH_TRANSLATED}e&quot;
RequestHeader set INFO_ORIG_SCRIPT_FILENAME &quot;%{INFO_ORIG_SCRIPT_FILENAME}e&quot;
RequestHeader set INFO_ORIG_SCRIPT_NAME &quot;%{INFO_ORIG_SCRIPT_NAME}e&quot;
RequestHeader set INFO_PATH &quot;%{INFO_PATH}e&quot;
RequestHeader set INFO_PATH_INFO &quot;%{INFO_PATH_INFO}e&quot;
RequestHeader set INFO_PHP_SELF &quot;%{INFO_PHP_SELF}e&quot;
RequestHeader set INFO_QUERY_STRING &quot;%{INFO_QUERY_STRING}e&quot;
RequestHeader set INFO_REDIRECT_QUERY_STRING &quot;%{INFO_REDIRECT_QUERY_STRING}e&quot;
RequestHeader set INFO_REDIRECT_REMOTE_USER &quot;%{INFO_REDIRECT_REMOTE_USER}e&quot;
RequestHeader set INFO_REDIRECT_STATUS &quot;%{INFO_REDIRECT_STATUS}e&quot;
RequestHeader set INFO_REDIRECT_URL &quot;%{INFO_REDIRECT_URL}e&quot;
RequestHeader set INFO_REMOTE_ADDR &quot;%{INFO_REMOTE_ADDR}e&quot;
RequestHeader set INFO_REMOTE_HOST &quot;%{INFO_REMOTE_HOST}e&quot;
RequestHeader set INFO_REMOTE_IDENT &quot;%{INFO_REMOTE_IDENT}e&quot;
RequestHeader set INFO_REMOTE_PORT &quot;%{INFO_REMOTE_PORT}e&quot;
RequestHeader set INFO_REMOTE_USER &quot;%{INFO_REMOTE_USER}e&quot;
RequestHeader set INFO_REQUEST_FILENAME &quot;%{INFO_REQUEST_FILENAME}e&quot;
RequestHeader set INFO_REQUEST_METHOD &quot;%{INFO_REQUEST_METHOD}e&quot;
RequestHeader set INFO_REQUEST_TIME &quot;%{INFO_REQUEST_TIME}e&quot;
RequestHeader set INFO_REQUEST_URI &quot;%{INFO_REQUEST_URI}e&quot;
RequestHeader set INFO_SCRIPT_FILENAME &quot;%{INFO_SCRIPT_FILENAME}e&quot;
RequestHeader set INFO_SCRIPT_GROUP &quot;%{INFO_SCRIPT_GROUP}e&quot;
RequestHeader set INFO_SCRIPT_NAME &quot;%{INFO_SCRIPT_NAME}e&quot;
RequestHeader set INFO_SCRIPT_URI &quot;%{INFO_SCRIPT_URI}e&quot;
RequestHeader set INFO_SCRIPT_URL &quot;%{INFO_SCRIPT_URL}e&quot;
RequestHeader set INFO_SCRIPT_USER &quot;%{INFO_SCRIPT_USER}e&quot;
RequestHeader set INFO_SERVER_ADDR &quot;%{INFO_SERVER_ADDR}e&quot;
RequestHeader set INFO_SERVER_ADMIN &quot;%{INFO_SERVER_ADMIN}e&quot;
RequestHeader set INFO_SERVER_NAME &quot;%{INFO_SERVER_NAME}e&quot;
RequestHeader set INFO_SERVER_PORT &quot;%{INFO_SERVER_PORT}e&quot;
RequestHeader set INFO_SERVER_PROTOCOL &quot;%{INFO_SERVER_PROTOCOL}e&quot;
RequestHeader set INFO_SERVER_SIGNATURE &quot;%{INFO_SERVER_SIGNATURE}e&quot;
RequestHeader set INFO_SERVER_SOFTWARE &quot;%{INFO_SERVER_SOFTWARE}e&quot;
RequestHeader set INFO_THE_REQUEST &quot;%{INFO_THE_REQUEST}e&quot;
RequestHeader set INFO_TIME &quot;%{INFO_TIME}e&quot;
RequestHeader set INFO_TIME_DAY &quot;%{INFO_TIME_DAY}e&quot;
RequestHeader set INFO_TIME_HOUR &quot;%{INFO_TIME_HOUR}e&quot;
RequestHeader set INFO_TIME_MIN &quot;%{INFO_TIME_MIN}e&quot;
RequestHeader set INFO_TIME_MON &quot;%{INFO_TIME_MON}e&quot;
RequestHeader set INFO_TIME_SEC &quot;%{INFO_TIME_SEC}e&quot;
RequestHeader set INFO_TIME_WDAY &quot;%{INFO_TIME_WDAY}e&quot;
RequestHeader set INFO_TIME_YEAR &quot;%{INFO_TIME_YEAR}e&quot;
RequestHeader set INFO_TZ &quot;%{INFO_TZ}e&quot;
RequestHeader set INFO_UNIQUE_ID &quot;%{INFO_UNIQUE_ID}e&quot;</pre>
<h2><a id="decoded"></a>Mod_Rewrite Variables Decoded!</h2>
<pre>[API_VERSION] =&gt; 20020903:12
[AUTH_TYPE] =&gt; Digest
[DOCUMENT_ROOT] =&gt; /home/user/www_root/askapache.com
[HTTPS] =&gt; off
[HTTP_ACCEPT] =&gt; text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
[HTTP_COOKIE] =&gt; PHPSESSID=752ee6d56e15f305233e30045987e5ce568c034; __qca=1176541225-59967328-5223185;
[HTTP_HOST] =&gt; www.askapache.com
[HTTP_REFERER] =&gt; http://www.askapache.com/protest/index.php?askapache=awesomeness&amp;you=rock
[HTTP_USER_AGENT] =&gt; Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
[IS_SUBREQ] =&gt; false
[QUERY_STRING] =&gt; e=404
[REMOTE_ADDR] =&gt; 22.162.144.211
[REMOTE_HOST] =&gt; 22.162.144.211
[REMOTE_PORT] =&gt; 4511
[REMOTE_USER] =&gt; administrator
[REQUEST_FILENAME] =&gt; /home/user/www_root/askapache.com/protest/index.php
[REQUEST_METHOD] =&gt; GET
[REQUEST_URI] =&gt; /protest/index.php
[SCRIPT_FILENAME] =&gt; /home/user/www_root/askapache.com/protest/index.php
[SCRIPT_GROUP] =&gt; daemonu
[SCRIPT_USER] =&gt; askapache
[SERVER_ADDR] =&gt; 208.113.134.190
[SERVER_ADMIN] =&gt; webmaster@askapache.com
[SERVER_NAME] =&gt; www.askapache.com
[SERVER_PORT] =&gt; 80
[SERVER_PROTOCOL] =&gt; HTTP/1.1
[SERVER_SOFTWARE] =&gt; Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2
[THE_REQUEST] =&gt; GET /protest/adf HTTP/1.1
[TIME] =&gt; 20080820014309
[TIME_DAY] =&gt; 20
[TIME_HOUR] =&gt; 01
[TIME_MIN] =&gt; 43
[TIME_MON] =&gt; 08
[TIME_SEC] =&gt; 09
[TIME_WDAY] =&gt; 3
[TIME_YEAR] =&gt; 2008</pre>
<h3>Request using HTTPS</h3>
<pre>[API_VERSION] =&gt; 20020903:12
[AUTH_TYPE] =&gt; Digest
[DOCUMENT_ROOT] =&gt; /home/user/www_root/askapache.com
[HTTPS] =&gt; on
[HTTP_ACCEPT] =&gt; text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
[HTTP_COOKIE] =&gt; PHPSESSID=752ee6d56e15f305233e30045987e5ce568c034; __qca=1176541225-59967328-5223185;
[HTTP_HOST] =&gt; www.askapache.com
[HTTP_REFERER] =&gt; http://www.askapache.com/protest/index.php?askapache=awesomeness&amp;you=rock
[HTTP_USER_AGENT] =&gt; Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
[IS_SUBREQ] =&gt; false
[QUERY_STRING] =&gt; hi=you&amp;whats=&amp;amp;you
[REMOTE_ADDR] =&gt; 22.162.144.211
[REMOTE_HOST] =&gt; 22.162.144.211
[REMOTE_PORT] =&gt; 4605
[REMOTE_USER] =&gt; administrator
[REQUEST_FILENAME] =&gt; /home/user/www_root/askapache.com/protest/index.php
[REQUEST_METHOD] =&gt; GET
[REQUEST_URI] =&gt; /protest/index.php
[SCRIPT_FILENAME] =&gt; /home/user/www_root/askapache.com/protest/index.php
[SCRIPT_GROUP] =&gt; daemonu
[SCRIPT_USER] =&gt; askapache
[SERVER_ADDR] =&gt; 208.113.134.190
[SERVER_ADMIN] =&gt; webmaster@askapache.com
[SERVER_NAME] =&gt; www.askapache.com
[SERVER_PORT] =&gt; 443
[SERVER_PROTOCOL] =&gt; HTTP/1.1
[SERVER_SOFTWARE] =&gt; Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2
[THE_REQUEST] =&gt; GET /protest/index.php?hi=you&amp;whats=&amp;amp;you HTTP/1.1
[TIME] =&gt; 20080820015016
[TIME_DAY] =&gt; 20
[TIME_HOUR] =&gt; 01
[TIME_MIN] =&gt; 50
[TIME_MON] =&gt; 08
[TIME_SEC] =&gt; 16
[TIME_WDAY] =&gt; 3
[TIME_YEAR] =&gt; 2008</pre>
<h2>Emulating ErrorDocuments with Mod_Rewrite</h2>
<p>The ErrorDocument directive is helpful because an errordocument is called differently then a normal file, and it contains special variables to help an admin debug.</p>
<p>I&#8217;ve wanted to use a RewriteCond + a RewriteRule to cause an Apache ErrorDocument to be displayed for a long time&#8230; I finally figured it out.  Simply use the <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">HTTP STATUS CODE trick</a> in combination with a simple RewriteRule to trigger an Apache ErrorDocument.</p>
<p>This code emulates the internal 404 process Apache goes through.. If the file is not found it requests the /test/trigger-error/404 internally which triggers the 404 ErrorDocument.</p>
<pre>ErrorDocument 404 /test/errordocument/404.html
Redirect 404 /test/trigger-error/404
&nbsp;
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} !=404
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /test/trigger-error/404 [L]</pre>
<p><strong>Big Deal..</strong> you might say&#8230; well consider that this works with any status code, and using this method you now have the power to trigger any errordocument page based on any kind of rewritecond.  I&#8217;ll be writing about some practical uses for this powerful method in the coming weeks, but heres a good example now so you can see how it can be used.</p>
<p>This bit of code Triggers the <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#status-505">505 HTTP Version Not Supported</a> When a request is made to the server with a protocol other than 1.1.</p>
<pre>ErrorDocument 505 /test/errordocument/505.html
Redirect 505 /test/trigger-error/505
&nbsp;
RewriteEngine On
RewriteBase /
&nbsp;
RewriteCond %{ENV:REDIRECT_STATUS} !=505
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /.*\ HTTP/(0\.9|1\.0|1\.1) [NC]
RewriteRule .* /test/trigger-error/505 [L]</pre>
<p class="anote"><strong>YES!</strong> I realize I didn&#8217;t explain that very well, I didn&#8217;t realize it was that complicated..  I wanted to go into how to use these advanced tricks and methods to achieve some really cool stuff, but explaining just this little bit took me awhile and I&#8217;m out of page space!</p>
<p>So play around with this and I&#8217;ll post back some of the <em>untapped sicknesses</em> you can give a website with such powerful methods at your disposal.</p>
<blockquote cite="http://httpd.apache.org/"><p>
<cite><strong>Ralf S. Engelschall</strong></cite></p>
<pre>/*
 *  URL Rewriting Module
 *
 *  This module uses a rule-based rewriting engine (based on a
 *  regular-expression parser) to rewrite requested URLs on the fly.
 *
 *  It supports an unlimited number of additional rule conditions (which can
 *  operate on a lot of variables, even on HTTP headers) for granular
 *  matching and even external database lookups (either via plain text
 *  tables, DBM hash files or even external processes) for advanced URL
 *  substitution.
 *
 *  It operates on the full URLs (including the PATH_INFO part) both in
 *  per-server context (httpd.conf) and per-dir context (.htaccess) and even
 *  can generate QUERY_STRING parts on result.   The rewriting result finally
 *  can lead to internal subprocessing, external request redirection or even
 *  to internal proxy throughput.
 *
 *  This module was originally written in April 1996 and
 *  gifted exclusively to the The Apache Software Foundation in July 1997 by
 *
 *      Ralf S. Engelschall
 *      rse engelschall.com
 *      www.engelschall.com
 */</pre>
</blockquote>
<p><a href="http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html"></a><a href="http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html">Crazy Advanced Mod_Rewrite Tutorial</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>mod_rewrite Fix for Caching Updated Files</title>
		<link>http://www.askapache.com/htaccess/mod_rewrite-fix-for-caching-updated-files.html</link>
		<comments>http://www.askapache.com/htaccess/mod_rewrite-fix-for-caching-updated-files.html#comments</comments>
		<pubDate>Sun, 30 Aug 2009 13:20:59 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[Cache-Control]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[If-Modified-Since]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Last-Modified]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://www.askapache.com/htaccess/mod_rewrite-code-to-fix-caching-updated-files.html</guid>
		<description><![CDATA[<p>Web Developers sometimes use <code>file.ext?v=004</code> as a version control system to force visitors to use updated files.  <strong>This is terrible.</strong>  Instead link to <code>apache-003.css</code> and set it to be cached forever. When you change the file you just change the links to <code>apache-004.css</code>. That eliminates millions of bandwidth and resource robbing If-Modified-Since requests. You only need Apache with mod_rewrite, and 1-10 minutes!</p>]]></description>
			<content:encoded><![CDATA[<p><strong>Web Developers sometimes use</strong> <code>file.ext?v=137</code> as a <strong>version control system</strong> so they can force visitors to use an updated file.  <strong>This is so terrible</strong>.  Instead link to <code>apache-003.css</code> and set it to be cached forever. When you change the file you just change the links to <code>apache-004.css</code>.</p>
<h2>Raw Speed Benefit</h2>
<p>This eliminates millions of bandwidth and resource robbing <code>304 If-Modified-Since</code> requests.</p>
<hr />
<h2>Renaming links vs. Renaming files</h2>
<p>On the server my files are named <strong>apache.css</strong> and <strong>apache.js</strong>, but in the xhtml I point to them using the names <code>apache-113.css</code> and <code>apache-113.js</code>, after I change the file I just add 1 to the number, and the new file is cached. They are internally redirected to apache.css and apache.js (invisible to the user) The concept is similar to a &#8220;shortcut&#8221; in windows or a symlink in BSD.  The trick is that I never actually rename the files on the server.  I just rename them in the html.  That means <code>apache-135.css</code> is served from the file apache.css but the browser/cache only see and know about <code>apache-135.css</code>.</p>
<h2>XHTML</h2>
<p><strong>NOTE</strong>: You can do your own investigating of this sites source code and <a href="http://www.askapache.com/online-tools/http-headers-tool/">HTTP headers</a> to see this whole system in action</p>
<pre>&lt;link href=&quot;http://static.askapache.com/z/c/apache-0031.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;script src=&quot;http://static.askapache.com/z/j/apache-0031.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<h2>mod_rewrite code for htaccess or httpd.conf</h2>
<p><strong>Updated:</strong> 10/20/2008</p>
<pre>RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /z/([a-z]+)/(.+)-([0-9]+)\.(js|css).*\ HTTP/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ /z/%2/%3.%5 [NC,L]</pre>
<h3>Alternate mod_rewrite code</h3>
<pre>RewriteEngine On
RewriteBase /
RewriteRule ^([cij]+)(/?[a-z]*)/([a-z]+)-([0-9]+)\.([a-z]+)$ /$1$2/$3.$5 [L]</pre>
<h2>Ideal Caching Scheme</h2>
<p>Ok so you want the xhtml to be the only file that isn&#8217;t cached without being validated, its simple to <a href="http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html" title="Speed Up Sites with htaccess Caching">setup your own caching scheme</a>.</p>
<h3>Bad Cache information for a file with the <code>?v=foo</code> hack</h3>
<blockquote><p>This object will be fresh for 1 week. It can be validated with Last-Modified. This object requests that a Cookie be set; this makes it and other pages affected automatically stale; clients must check them upon every request. Because it contains a query (&#8216;?&#8217;) in the URL, many caches will not keep this object.</p>
</blockquote>
<p><a href="http://www.askapache.com/htaccess/mod_rewrite-fix-for-caching-updated-files.html"></a><a href="http://www.askapache.com/htaccess/mod_rewrite-fix-for-caching-updated-files.html">mod_rewrite Fix for Caching Updated Files</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/mod_rewrite-fix-for-caching-updated-files.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An AskApache Plugin Upgrade to Rule them All</title>
		<link>http://www.askapache.com/wordpress/an-askapache-plugin-upgrade-to-rule-them-all.html</link>
		<comments>http://www.askapache.com/wordpress/an-askapache-plugin-upgrade-to-rule-them-all.html#comments</comments>
		<pubDate>Wed, 29 Jul 2009 17:59:07 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[401]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[AskApache Google 404]]></category>
		<category><![CDATA[AskApache Password Protection]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Cache-Control]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[Etags]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[FilesMatch]]></category>
		<category><![CDATA[Fsockopen]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[htaccess files]]></category>
		<category><![CDATA[htaccess tricks]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Last-Modified]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[mod_include]]></category>
		<category><![CDATA[Mod_Setenvif]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[password protection]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[server config]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[SetEnvIf]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Socket]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Username]]></category>
		<category><![CDATA[Wireshark]]></category>
		<category><![CDATA[WordPress Security]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3062</guid>
		<description><![CDATA[<p><a class="IFL" href="http://uploads.askapache.com/2009/07/apache-server-status.png"><img src="http://uploads.askapache.com/2009/07/apache-server-status-350x164.png" alt="apache-server-status" title="apache-server-status" width="350" height="164" class="alignnone size-medium wp-image-3070" /></a>So my blog as been rather quiet for almost a year now, and very few updates if any have been released for my Password Protection PLugin, my Google 404 Plugin, and definately not for my AskApache CrazyCache plugin, which I will be releasing last...  So for all of you who've helped me out by sending me suggestions and notifying me of errors and sticking with it...  Just wanted to <strong>say sorry about that, and thanks for all the great ideas.. </strong> Well, I've been sticking with it as well believe it our not.  I manage to get free days once in a while, and then its <strong>time to jam</strong>.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://uploads.askapache.com/2009/07/apache-server-status.png" rel="nofollow" class="IFL" ><img src="http://uploads.askapache.com/2009/07/apache-server-status-350x164.png" alt="An AskApache Plugin Upgrade to Rule them All" title="apache-server-status" width="350" height="164" class="alignnone size-medium wp-image-3070" /></a>So my blog as been rather quiet for almost a year now, and very few updates if any have been released for my Password Protection PLugin, my Google 404 Plugin, and definately not for my AskApache CrazyCache plugin, which I will be releasing last&#8230;  So for all of you who&#8217;ve helped me out by sending me suggestions and notifying me of errors and sticking with it&#8230;  Just wanted to <strong>say sorry about that, and thanks for all the great ideas.. </strong> Well, I&#8217;ve been sticking with it as well believe it our not.  I manage to get free days once in a while, and then its <strong>time to jam</strong>.</p>
<p>I&#8217;ve used just about every CMS/Blog/Forum/Trac/Gallery/etc) and really didn&#8217;t like a lot of the way they coded&#8230;  I could use php but I didn&#8217;t KNOW php.. so I&#8217;ve had to learn php also, and it was tough to learn the advanced class usage and all the other language specific (but similar) constructs for php.  It was especially difficult (but fun and challenging) to program so as to be compatible with php4 and php5 (Such is WordPress).    But I kept at it, and soon you can decide for yourself what to make of it.</p>
<p>I can code in plenty of languages (bash, lua, windows .bat and vbs,  ocaml, big fan of all things shell) and can work my way through C and even sorta somewhat with assembly.  Assembly is the hardest, by far,  I&#8217;m into easy and powerful languages like Python, Javascript, perl, php, ruby, and CGI. I&#8217;ve used PHP for a long time to do various things,  but never to build software projects like this.  Once I noticed WordPress&#8217;s core .php files and the excellent programming I wanted to try and learn hot to do it.   The WordPress code is some of the best I&#8217;ve seen.  It appears the way they built it was planned, and not just dreamt up while typing that I can&#8217;t help but do.    Every time I read through the core code I learn a new trick or very nice way to do something.  Those guys are really good, and I think WordPress is going to dominate for a long long time.</p>
<h2>The Strategy</h2>
<p>The Password Protection (passpro) plugin has a lot of complex stuff going on, especially for a newbie to PHP and WordPress like me, so after refactoring the whole thing at least 5 times I decided to modify my approach, and wrote the AskApache Google 404 Plugin as a way to practice on a simpler piece of code, while at the same time providing a plugin of value.   Eventually I stopped thinking I could just code the whole thing in one sit-down with a stream-of-consciousness, and had to instead modularize the code and focus in on each part before moving to the next (I go without a plan because its fun, just not the most productive, but again, I&#8217;m not a programmer in the scientific sense.).</p>
<p>So I decided I had to really learn how WordPress Plugins work, filters, hooks, actions, and basically comfortability at reverse-engineering code, (Im a beginner for the last time), and so with the upcoming release of the AskApache Google 404 Plugin I have succeeded in making an incredibly stable plugin.  That way I only have to worry about what the aapasspro plugin is doing, instead of trying to fit it into a framework.  </p>
<h2>AskApache Google 404 Upgrade</h2>
<p>I think its rather unusual to develop a nice plugin like this 404 handler merely for the purpose of improving upon another plugin, but hey it worked.  As of <em>08/03/2009 14:06PM EST</em> I have about 1 hour left of finishing touches to release this upgrade.  But as you cantell by my badly edited posts, I don&#8217;t have a lot of time to myself.  An hour here and there is about it.  So it could be up to 2 weeks before I actually have the time to commit the release to the repo.  On a sidenote, have you checked out <a href="http://windows7news.com/" rel="nofollow"  title="Windows 7 News">Windows 7 News</a>?  I&#8217;ve been contracted to do some technical work for them and thought they had an excellent site.</p>
<p><a href="http://uploads.askapache.com/2009/07/askapache-google-upgrade-ss1.png" rel="nofollow" ><img src="http://uploads.askapache.com/2009/07/askapache-google-upgrade-ss1-344x350.png" alt="An AskApache Plugin Upgrade to Rule them All" title="askapache-google-upgrade-ss1" width="344" height="350" class="alignnone size-medium wp-image-3139" /></a></p>
<p><a href="http://uploads.askapache.com/2009/07/askapache-google-upgrade-ss2.png" rel="nofollow" ><img src="http://uploads.askapache.com/2009/07/askapache-google-upgrade-ss2-293x350.png" alt="An AskApache Plugin Upgrade to Rule them All" title="askapache-google-upgrade-ss2" width="293" height="350" class="alignnone size-medium wp-image-3138" /></a></p>
<p>But keep in mind, the 404 PLugin is just where I practice for the passpro plugin, which truly does have features that no other software like it has ever had.  I understand the technology behind this plugin, and know it would really have a great impact on improving the Web (esp. WordPress) for all of us, I&#8217;ve just had to learn how to make it.</p>
<h2>AskApache Password Protection</h2>
<p>Probably still a couple weeks away, this plugin is the ultimate culmination of apache hackers dreams, at least those on shared servers (who may be interested in learning how to bypass security of said servers)..  So this is something I have much too fun with doing what I like to do.. network/protocol-level security.  I&#8217;ve examined the source code for many software packages that I use or have used to audit a server&#8217;s security, and this simple php plugin in most instances can enumerate with accuraccy most of the server&#8217;s setup in about a minute.  The catch (and the file permission problems I had to find a workaround too) is that this software is launched on the server, not remotely against the server.</p>
<p>Some of the software I examined was whiskers, nessus, nmap, hping, mozilla source, wireshark, ncftp, netcat, etc..  The closest comparison to the socket-level class I&#8217;ve hacked together to those is wireshark.  Except that wireshark only interprets (captures) the data passing over the wire, while this class does that and in fact sends and receives the data like netcat or nmap.  Its really more similar to metasploit, and can easily be used to send hex, binary, ascii, or any type of payload to the remote or local host.</p>
<h2>The Upgrades Begin</h2>
<p>Well I started working on them a long time ago.  Both the Password Protection plugin and the Google 404 plugin needed serious work.   And I finally have it all figured out.  Essentially I would work on one and finish an upgrade, but I just wasn&#8217;t happy with it and I wold start all over again, refactoring the code.   So as I put the finishing touches on those 2 plugins keep an eye out.  They are major upgrades.   I was able to meet all the goals I had for them, and came up with a lot of more improvements during the process.One of the main things I needed was a socket-level class to perform all kinds of checks and tests on.  I need this also for my crazy cache plugin, which my blog is currently using ,  and I have a 2 more really nice pplugins I use that also needed  access to a network class.  I wrote about what I was doing with fsockopen, and I&#8217;ve been improving on that example ever since.  I use this class to do some really powerful and exciting stuff, but you&#8217;ll see it soon enough.  As an indication of &#8216;getting it right&#8217; for the Password Protection plugin, the plugin will now work on Windows, Apache, IIS, Lighthttpd, and will even work running on a blackberry web server.  So now everyone using wordpress can at least get some security()</p>
<p class="enote">Many of the the other improvements focus on using the fsockopen class and .htaccess tricks to basically enumerate and discover all the different capabilities of your particular server;  That way you can learn about all the features and security that are possible for your specific server, and the securty modules wi8ll be geared for that as well.  FINALLY this plugin is going to be stable, and I just cant wait to see how people react when they learn all great capability their Apache-based Server has that they didn&#8217;t have a clue about.   Its amazing in that sense, and hackers will love theh way it works.. but your server admins will love it even more because its entirely 100% focused on helping you to set your site up (if you have Apache) to keep spammers out, to keep virii-serving robots and their log-hogging exploit requests and CPU/Mem robiing 404 errors off of your servers for real.  This will have a noticeable affect to whoever is running the server.   As you can tell.. I am pumped!</br></p>
<hr class="C" />
Apache is easy to configure and use, but only when you have root access.  Most people on shared and private hosting aren&#8217;t even able to view the main config file, let alone execute the Apache binaries to see what features are available and what configuration is being used.<br class="C" /></p>
<p>Apache can only be influenced by the main server configs and by .htaccess files.  Not by php, not by perl, and the main configs are almost never accessible to the masses.  But .htaccess files are.  And many hosting providers allow and enable .htaccess files, a configuration file for your web server.  The advanced features and capabilities of Apache were out of reach for most of us, it just wasn&#8217;t possible to enumerate or access, and most hosting providers are infamous for their lack of .htaccess (customer) support.  This plugin goes around those problems to give the power back to the people.<br class="C" /></p>
<p>y creating custom .htaccess files containing unpublished .htaccess tricks and techniques and combining that with the use of socket-level networking from WordPress (PHP) using <a href="http://www.askapache.com/php/fsockopen-socket.html">fsockopen</a>, we can effectively enumerate and discover an incredible amount of features and settings you will be able to control and use with this plugin.</p>
<p>Here are a few examples of the capabilities of this plugin, some of which I believe no other software can do..  <em>(Open source free to copy!)</em>.</p>
<ol>
<li>Current Version of Apache (<strong>Down to the API Version</strong>)</li>
<li>List of <strong>ALL Modules currently enabled</strong> by Apache (Such as Mod_Rewrite)</li>
<li>List of <strong>ALL Directives enabled by EACH enabled Module.</strong></li>
<li>Enumerate .htaccess Overrides, Context Permissions</li>
<li>Test for any builtin Handlers (like the <a href="http://uploads.askapache.com/2009/07/apache-server-status.png" rel="nofollow" >status handler screenshot</a>)</li>
<li>Configure SSI (<a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-security">http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-security</a>)</li>
</ol>
<blockquote cite="http://www.askapache.com/htaccess/password-protection-plugin-status.html"><div class="inote"><cite><a href="http://www.askapache.com/htaccess/password-protection-plugin-status.html"></a></cite>
<p><strong>March 1, 2009</strong><br /><strong>I would focus on the method that WordPress uses</strong>.  The code they have now (2.8 bleeding-edge) still isn&#8217;t where it needs to be, but this is some difficult stuff and <strong>they have a brilliant start, it&#8217;ll work.. just a question of when</strong>.</p>
<p><a href="http://uploads.askapache.com/2009/03/apache-security-model-tall1.png" rel="nofollow" class="IFL" ><img src="http://uploads.askapache.com/2009/03/apache-security-model-tall1-250x123.png" alt="Apache Security Model - In Color" title="apache-security-model-wide" width="250" height="123" /></a><strong>The main issue</strong> with the password protection plugin working for some people and not others is due to <a href="http://www.askapache.com/security/chmod-stat.html"title="detailed file permission article" >file permission configurations</a>.  The plugin attempts to write/modify files in your blog&#8217;s root directory.<br class="C" /></p>
</div>
</blockquote>
<hr class="C" />
<blockquote cite="http://www.askapache.com/htaccess/htaccess-plugin-blocks-spam-hackers-and-password-protects-blog.html"><div class="inote"><cite><a href="http://www.askapache.com/htaccess/htaccess-plugin-blocks-spam-hackers-and-password-protects-blog.html"></a></cite>
<p><strong>November 05, 2008</strong><br />To make a long story short, I downloaded each major release of the apache httpd source code starting at version 1.3.0 and finishing with version 2.2.11, I then compiled each version and built a HTTPD from source for all these apache versions.</p>
<div>
<div style="width:100px;overflow:hidden;float:left;">
<ul>
<li>1.3.0</li>
<li>1.3.1</li>
<li>1.3.11</li>
<li>1.3.12</li>
<li>1.3.14</li>
<li>1.3.17</li>
<li>1.3.19</li>
<li>1.3.2</li>
<li>1.3.20</li>
<li>1.3.22</li>
<li>1.3.23</li>
<li>1.3.24</li>
<li>1.3.27</li>
<li>1.3.28</li>
</ul>
</div>
<div style="width:100px;overflow:hidden;float:left;">
<ul>
<li>1.3.29</li>
<li>1.3.3</li>
<li>1.3.31</li>
<li>1.3.32</li>
<li>1.3.33</li>
<li>1.3.34</li>
<li>1.3.35</li>
<li>1.3.36</li>
<li>1.3.37</li>
<li>1.3.39</li>
<li>1.3.4</li>
<li>1.3.41</li>
<li>1.3.6</li>
<li>1.3.9</li>
</ul>
</div>
<div style="width:100px;overflow:hidden;float:left;">
<ul>
<li>2.0.35</li>
<li>2.0.36</li>
<li>2.0.39</li>
<li>2.0.40</li>
<li>2.0.42</li>
<li>2.0.43</li>
<li>2.0.44</li>
<li>2.0.45</li>
<li>2.0.46</li>
<li>2.0.47</li>
<li>2.0.48</li>
<li>2.0.49</li>
<li>2.0.50</li>
<li>2.0.51</li>
</ul>
</div>
<div style="width:150px;overflow:hidden;float:left;">
<ul>
<li>2.0.52</li>
<li>2.0.53</li>
<li>2.0.54</li>
<li>2.0.55</li>
<li>2.0.58</li>
<li>2.0.59</li>
<li>2.0.61</li>
<li>2.0.63</li>
<li>2.1.3-beta</li>
<li>2.1.6-alpha</li>
<li>2.1.7-beta</li>
<li>2.1.8-beta</li>
<li>2.1.9-beta</li>
</ul>
</div>
<div style="width:100px;overflow:hidden;float:left;">
<ul>
<li>2.2.0</li>
<li>2.2.10</li>
<li>2.2.2</li>
<li>2.2.3</li>
<li>2.2.4</li>
<li>2.2.6</li>
<li>2.2.8</li>
<li>2.2.9</li>
<li><strong>2.2.10</strong></li>
<li><strong>2.2.11</strong></li>
</ul>
</div>
<p><br class="C" /></div>
<p>Then I went through each version and determined the compatible modules for that version, and I&#8217;m pretty confident that I was also able to find each and every directive allowed by the compatible modules for that version (including core directives).  See <a href="http://www.askapache.com/htaccess/htaccess.html#htaccess-directives">.htaccess directive list</a>.  Basically I can now test a server using a variety of methods and determine almost 100% accurately what version of Apache (down to the API) is running, what modules (and versions) are enabled, and each and every directive that is allowed or disallowed for that version.  So this is so awesome because now we can enable all sorts of additional security features.</p>
</div>
</blockquote>
<hr class="C" />
<blockquote cite="http://www.askapache.com/htaccess/htaccess.html#htaccess-modules"><p><cite><a href="http://www.askapache.com/htaccess/htaccess.html#htaccess-modules">Htaccess enabled Modules</a></cite>
<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="http://www.askapache.com/servers/mod_actions.c.html">mod_actions</a>, <a href="http://www.askapache.com/servers/mod_alias.c.html">mod_alias</a>, <a href="http://www.askapache.com/servers/mod_asis.c.html">mod_asis</a>, <a href="http://www.askapache.com/servers/mod_auth_basic.c.html">mod_auth_basic</a>, <a href="http://www.askapache.com/servers/mod_auth_digest.c.html">mod_auth_digest</a>, <a href="http://www.askapache.com/servers/mod_authn_anon.c.html">mod_authn_anon</a>, <a href="http://www.askapache.com/servers/mod_authn_dbd.c.html">mod_authn_dbd</a>, <a href="http://www.askapache.com/servers/mod_authn_dbm.c.html">mod_authn_dbm</a>, <a href="http://www.askapache.com/servers/mod_authn_default.c.html">mod_authn_default</a>, <a href="http://www.askapache.com/servers/mod_authn_file.c.html">mod_authn_file</a>, <a href="http://www.askapache.com/servers/mod_authz_dbm.c.html">mod_authz_dbm</a>, <a href="http://www.askapache.com/servers/mod_authz_default.c.html">mod_authz_default</a>, <a href="http://www.askapache.com/servers/mod_authz_groupfile.c.html">mod_authz_groupfile</a>, <a href="http://www.askapache.com/servers/mod_authz_host.c.html">mod_authz_host</a>, <a href="http://www.askapache.com/servers/mod_authz_owner.c.html">mod_authz_owner</a>, <a href="http://www.askapache.com/servers/mod_authz_user.c.html">mod_authz_user</a>, <a href="http://www.askapache.com/servers/mod_autoindex.c.html">mod_autoindex</a>, <a href="http://www.askapache.com/servers/mod_cache.c.html">mod_cache</a>, <a href="http://www.askapache.com/servers/mod_cern_meta.c.html">mod_cern_meta</a>, <a href="http://www.askapache.com/servers/mod_cgi.c.html">mod_cgi</a>, <a href="http://www.askapache.com/servers/mod_dav.c.html">mod_dav</a>, <a href="http://www.askapache.com/servers/mod_dav_fs.c.html">mod_dav_fs</a>, <a href="http://www.askapache.com/servers/mod_dbd.c.html">mod_dbd</a>, <a href="http://www.askapache.com/servers/mod_deflate.c.html">mod_deflate</a>, <a href="http://www.askapache.com/servers/mod_dir.c.html">mod_dir</a>, <a href="http://www.askapache.com/servers/mod_disk_cache.c.html">mod_disk_cache</a>, <a href="http://www.askapache.com/servers/mod_dumpio.c.html">mod_dumpio</a>, <a href="http://www.askapache.com/servers/mod_env.c.html">mod_env</a>, <a href="http://www.askapache.com/servers/mod_expires.c.html">mod_expires</a>, <a href="http://www.askapache.com/servers/mod_ext_filter.c.html">mod_ext_filter</a>, <a href="http://www.askapache.com/servers/mod_file_cache.c.html">mod_file_cache</a>, <a href="http://www.askapache.com/servers/mod_filter.c.html">mod_filter</a>, <a href="http://www.askapache.com/servers/mod_headers.c.html">mod_headers</a>, <a href="http://www.askapache.com/servers/mod_ident.c.html">mod_ident</a>, <a href="http://www.askapache.com/servers/mod_imagemap.c.html">mod_imagemap</a>, <a href="http://www.askapache.com/servers/mod_include.c.html">mod_include</a>, <a href="http://www.askapache.com/servers/mod_info.c.html">mod_info</a>, <a href="http://www.askapache.com/servers/mod_log_config.c.html">mod_log_config</a>, <a href="http://www.askapache.com/servers/mod_log_forensic.c.html">mod_log_forensic</a>, <a href="http://www.askapache.com/servers/mod_logio.c.html">mod_logio</a>, <a href="http://www.askapache.com/servers/mod_mem_cache.c.html">mod_mem_cache</a>, <a href="http://www.askapache.com/servers/mod_mime.c.html">mod_mime</a>, <a href="http://www.askapache.com/servers/mod_mime_magic.c.html">mod_mime_magic</a>, <a href="http://www.askapache.com/servers/mod_negotiation.c.html">mod_negotiation</a>, <a href="http://www.askapache.com/servers/mod_proxy.c.html">mod_proxy</a>, <a href="http://www.askapache.com/servers/mod_proxy_ajp.c.html">mod_proxy_ajp</a>, <a href="http://www.askapache.com/servers/mod_proxy_balancer.c.html">mod_proxy_balancer</a>, <a href="http://www.askapache.com/servers/mod_proxy_connect.c.html">mod_proxy_connect</a>, <a href="http://www.askapache.com/servers/mod_proxy_ftp.c.html">mod_proxy_ftp</a>, <a href="http://www.askapache.com/servers/mod_proxy_http.c.html">mod_proxy_http</a>, <a href="http://www.askapache.com/servers/mod_rewrite.c.html">mod_rewrite</a>, <a href="http://www.askapache.com/servers/mod_setenvif.c.html">mod_setenvif</a>, <a href="http://www.askapache.com/servers/mod_speling.c.html">mod_speling</a>, <a href="http://www.askapache.com/servers/mod_ssl.c.html">mod_ssl</a>, <a href="http://www.askapache.com/servers/mod_status.c.html">mod_status</a>, <a href="http://www.askapache.com/servers/mod_substitute.c.html">mod_substitute</a>, <a href="http://www.askapache.com/servers/mod_unique_id.c.html">mod_unique_id</a>, <a href="http://www.askapache.com/servers/mod_userdir.c.html">mod_userdir</a>, <a href="http://www.askapache.com/servers/mod_usertrack.c.html">mod_usertrack</a>, <a href="http://www.askapache.com/servers/mod_version.c.html">mod_version</a>, <a href="http://www.askapache.com/servers/mod_vhost_alias.c.html">mod_vhost_alias</a></p>
</blockquote>
<hr class="C" />
<hr class="C" />
<h2>Debugging HTTP protocol</h2>
<p>Check this out!  I&#8217;m particularly happy about this feature, which outputs an exact trace of any requests made by the plugin (such as during the testing phase) by saving the actual raw data sent out on the wire using fsockopen, RX and TX.  This is useful for a number of reasons, viewing your headers, finding Redirect Loops, testing RewriteRules, and following the request hop-by-hop for debugging.  The below example shows 2 requests for 2 URIs.  The first URI is protected using Digest Authentication, the 2nd shows Basic.</p>
<pre> ______________
|  RAW TRACE   |
==================================================================================================================================
GET /htaccess/index.txt?testing=query HTTP/1.1
Host: www.askapache.com
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1) AA_PassPro/1.9 (http://www.askapache.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: close
Referer: http://www.askapache.com/
&nbsp;
HTTP/1.1 401 Authorization Required
Date: Wed, 22 Jul 2009 06:29:58 GMT
Server: Apache
WWW-Authenticate: Digest realm=&quot;do or die&quot;, nonce=&quot;03328f3ec7c7b&quot;, algorithm=MD5, domain=&quot;/&quot;, qop=&quot;auth&quot;
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 882
Connection: close
Content-Type: text/html; charset=UTF-8
&nbsp;
GET /htaccess/index.txt?testing=query HTTP/1.1
Host: www.askapache.com
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1) AA_PassPro/1.9 (http://www.askapache.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: close
Referer: http://www.askapache.com/
Authorization: Digest username=&quot;test&quot;,realm=&quot;do or die&quot;,nonce=&quot;03328f3ec7c7b&quot;,uri=&quot;/htaccess/index.txt?testing=query&quot;,
cnonce=&quot;82d057852a9dc497&quot;,nc=00000001,algorithm=MD5,response=&quot;9d476e9ea3&quot;,qop=&quot;auth&quot;
&nbsp;
HTTP/1.1 200 OK
Date: Wed, 22 Jul 2009 06:29:58 GMT
Server: Apache
Authentication-Info: rspauth=&quot;9051b01ee26dd62b3e2b40dada694f45&quot;, cnonce=&quot;82d057852a9dc497&quot;, nc=00000001, qop=auth
Last-Modified: Tue, 21 Jul 2009 23:56:00 GMT
Accept-Ranges: bytes
Cache-Control: max-age=3600
Expires: Wed, 22 Jul 2009 07:29:58 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 27
Connection: close
Content-Type: text/plain; charset=UTF-8
&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;&#96;`
&nbsp;
 ______________
|  RAW TRACE   |
==================================================================================================================================
GET /htaccess/po.txt?testing=query HTTP/1.1
Host: www.askapache.com
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1) AA_PassPro/1.9 (http://www.askapache.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: close
Referer: http://www.askapache.com/
&nbsp;
HTTP/1.1 401 Authorization Required
Date: Wed, 22 Jul 2009 06:29:58 GMT
Server: Apache
WWW-Authenticate: Basic realm=&quot;Po Pimping&quot;
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 878
Connection: close
Content-Type: text/html; charset=UTF-8
&nbsp;
GET /htaccess/po.txt?testing=query HTTP/1.1
Host: www.askapache.com
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1) AA_PassPro/1.9 (http://www.askapache.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: close
Referer: http://www.askapache.com/
Authorization: Basic adfAGAltcA==
&nbsp;
HTTP/1.1 200 OK
Date: Wed, 22 Jul 2009 06:29:58 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 05:54:39 GMT
Accept-Ranges: bytes
Cache-Control: max-age=3600
Expires: Wed, 22 Jul 2009 07:29:58 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 27
Connection: close
Content-Type: text/plain; charset=UTF-8
&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;`&#96;&#96;`</pre>
<h2>.htaccess Directives</h2>
<p>AcceptFilter, AcceptMutex, AcceptPathInfo, AccessFileName, Action, AddAlt, AddAltByEncoding, AddAltByType, AddCharset, AddDefaultCharset, AddDescription, AddEncoding, AddHandler, AddIcon, AddIconByEncoding, AddIconByType, AddInputFilter, AddLanguage, AddModuleInfo, AddOutputFilter, AddOutputFilterByType, AddType, Alias, AliasMatch, AllowCONNECT, AllowEncodedSlashes, AllowOverride, Anonymous, Anonymous_Authoritative, Anonymous_LogEmail, Anonymous_MustGiveEmail, Anonymous_NoUserID, Anonymous_NoUserId, Anonymous_VerifyEmail, AssignUserId, AuthAuthoritative, AuthBasicAuthoritative, AuthBasicProvider, AuthDBDUserPWQuery, AuthDBDUserRealmQuery, AuthDBM, AuthDBMAuthoritative, AuthDBMGroupFile, AuthDBMType, AuthDBMUserFile, AuthDefaultAuthoritative, AuthDigestAlgorithm, AuthDigestDomain, AuthDigestFile, AuthDigestGroupFile, AuthDigestNcCheck, AuthDigestNonceFormat, AuthDigestNonceLifetime, AuthDigestProvider, AuthDigestQop, AuthDigestShmemSize, AuthGroupFile, AuthLDAPAuthzEnabled, AuthLDAPBindDN, AuthLDAPBindON, AuthLDAPBindPassword, AuthLDAPCharsetConfig, AuthLDAPCompareDNOnServer, AuthLDAPDereferenceAliases, AuthLDAPEnabled, AuthLDAPFrontPageHack, AuthLDAPGroupAttribute, AuthLDAPGroupAttributeIsDN, AuthLDAPRemoteUserAttribute, AuthLDAPRemoteUserIsDN, AuthLDAPStartTLS, AuthLDAPURL, AuthLDAPUrl, AuthName, AuthType, AuthUserFile, AuthzDBMAuthoritative, AuthzDBMType, AuthzDefaultAuthoritative, AuthzGroupFileAuthoritative, AuthzLDAPAuthoritative, AuthzOwnerAuthoritative, AuthzUserAuthoritative, BS2000Account, BalancerMember, BrowserMatch, BrowserMatchNoCase, BufferedLogs, CGIMapExtension, CacheDefaultExpire, CacheDirLength, CacheDirLevels, CacheDisable, CacheEnable, CacheExpiryCheck, CacheFile, CacheForceCompletion, CacheGcClean, CacheGcDaily, CacheGcInterval, CacheGcMemUsage, CacheGcUnused, CacheIgnoreCacheControl, CacheIgnoreHeaders, CacheIgnoreNoLastMod, CacheLastModifiedFactor, CacheMaxExpire, CacheMaxFileSize, CacheMaxStreamingBuffer, CacheMinFileSize, CacheNegotiatedDocs, CacheRoot, CacheSize, CacheStoreNoStore, CacheStorePrivate, CacheTimeMargin, CharsetDefault, CharsetOptions, CharsetSourceEnc, CheckCaseOnly, CheckSpelling, ChildPerUserId, ContentDigest, CookieDomain, CookieExpires, CookieLog, CookieName, CookieStyle, CookieTracking, CoreDumpDirectory, CustomLog, DAV, DAVDepthInfinity, DAVGenericLockDB, DAVMinTimeout, DBDExptime, DBDKeep, DBDMax, DBDMin, DBDParams, DBDPersist, DBDPrepareSQL, DBDriver, Dav, DavDepthInfinity, DavGenericLockDB, DavLockDB, DavMinTimeout, DefaultIcon, DefaultLanguage, DefaultType, DeflateBufferSize, DeflateCompressionLevel, DeflateFilterNote, DeflateMemLevel, DeflateWindowSize, Directory, DirectoryIndex, DirectoryMatch, DirectorySlash, DocumentRoot, DumpIOInput, DumpIOOutput, EnableExceptionHook, EnableMMAP, EnableSendfile, ErrorDocument, ErrorLog, Example, ExpiresActive, ExpiresByType, ExpiresDefault, ExtFilterDefine, ExtFilterOptions, ExtendedStatus, FancyIndexing, FileETag, Files, FilesMatch, FilterChain, FilterDeclare, FilterProtocol, FilterProvider, FilterTrace, ForceLanguagePriority, ForceType, ForensicLog, GprofDir, GracefulShutdownTimeout, Group, Header, HeaderName, HostNameLookups, HostnameLookups, ISAIPFakeAsync, ISAPIAppendLogToErrors, ISAPIAppendLogToQuery, ISAPICacheFile, ISAPIFakeAsync, ISAPILogNotSupported, ISAPIReadAheadBuffer, IdentityCheck, IdentityCheckTimeout, IfDefine, IfModule, IfVersion, ImapBase, ImapDefault, ImapMenu, Include, IndexIgnore, IndexOptions, IndexOrderDefault, IndexStyleSheet, KeepAlive, KeepAliveTimeout, LDAPCacheEntries, LDAPCacheTTL, LDAPCertDBPath, LDAPConnectionTimeout, LDAPOpCacheEntries, LDAPOpCacheTTL, LDAPSharedCacheFile, LDAPSharedCacheSize, LDAPTrustedClientCert, LDAPTrustedGlobalCert, LDAPTrustedMode, LDAPVerifyServerCert, LanguagePriority, Limit, LimitExcept, LimitInternalRecursion, LimitRequestBody, LimitRequestFields, LimitRequestFieldsize, LimitRequestLine, LimitXMLRequestBody, Listen, ListenBacklog, LoadFile, LoadModule, Location, LocationMatch, LockFile, LogFormat, LogLevel, MCacheMaxObjectCount, MCacheMaxObjectSize, MCacheMaxStreamingBuffer, MCacheMinObjectSize, MCacheRemovalAlgorithm, MCacheSize, MMapFile, MaxClients, MaxKeepAliveRequests, MaxMemFree, MaxRequestsPerChild, MaxSpareServers, MaxSpareThreads, MaxSpareThreadsPerChild, MaxThreads, MetaDir, MetaFiles, MetaSuffix, MimeMagicFile, MinSpareServers, MinSpareThreads, ModMimeUsePathInfo, MultiviewsMatch, NWSSLTrustedCerts, NWSSLUpgradeable, NameVirtualHost, NoProxy, NumServers, Options, PassEnv, PerlAccessHandler, PerlAuthenHandler, PerlAuthzHandler, PerlChildExitHandler, PerlChildInitHandler, PerlCleanupHandler, PerlDispatchHandler, PerlFixupHandler, PerlFreshRestart, PerlHandler, PerlHeaderParserHandler, PerlInitHandler, PerlLogHandler, PerlModule, PerlPassEnv, PerlPostReadRequestHandler, PerlRequire, PerlRestartHandler, PerlSendHeader, PerlSetEnv, PerlSetVar, PerlSetupEnv, PerlTaintCheck, PerlTransHandler, PerlTypeHandler, PerlWarn, PidFile, Port, Protocol, ProtocolEcho, Proxy, ProxyBadHeader, ProxyBlock, ProxyDomain, ProxyErrorOverride, ProxyFtpDirCharset, ProxyIOBufferSize, ProxyMatch, ProxyMaxForwards, ProxyPass, ProxyPassInterpolateEnv, ProxyPassMatch, ProxyPassReverse, ProxyPassReverseCookieDomain, ProxyPassReverseCookiePath, ProxyPreserveHost, ProxyReceiveBufferSize, ProxyRemote, ProxyRemoteMatch, ProxyRequests, ProxySet, ProxyStatus, ProxyTimeout, ProxyVia, RLimitCPU, RLimitMEM, RLimitNPROC, ReadmeName, Redirect, RedirectMatch, RedirectPermanent, RedirectTemp, RemoveCharset, RemoveEncoding, RemoveHandler, RemoveInputFilter, RemoveLanguage, RemoveOutputFilter, RemoveType, RequestHeader, Require, RewriteBase, RewriteCond, RewriteEngine, RewriteLock, RewriteLog, RewriteLogLevel, RewriteMap, RewriteOptions, RewriteRule, SSIAccessEnable, SSIEndTag, SSIErrorMsg, SSIStartTag, SSITimeFormat, SSIUndefinedEcho, SSLCACertificateFile, SSLCACertificatePath, SSLCADNRequestFile, SSLCADNRequestPath, SSLCARevocationFile, SSLCARevocationPath, SSLCertificateChainFile, SSLCertificateFile, SSLCertificateKeyFile, SSLCipherSuite, SSLCryptoDevice, SSLEngine, SSLHonorCipherOrder, SSLLog, SSLLogLevel, SSLMutex, SSLOptions, SSLPassPhraseDialog, SSLProtocol, SSLProxyCACertificateFile, SSLProxyCACertificatePath, SSLProxyCARevocationFile, SSLProxyCARevocationPath, SSLProxyCipherSuite, SSLProxyEngine, SSLProxyMachineCertificateFile, SSLProxyMachineCertificatePath, SSLProxyProtocol, SSLProxyVerify, SSLProxyVerifyDepth, SSLRandomSeed, SSLRequire, SSLRequireSSL, SSLSessionCache, SSLSessionCacheTimeout, SSLUserName, SSLVerifyClient, SSLVerifyDepth, Satisfy, ScoreBoardFile, Script, ScriptAlias, ScriptAliasMatch, ScriptInterpreterSource, ScriptLog, ScriptLogBuffer, ScriptLogLength, ScriptStock, SecureListen, SendBufferSize, ServerAdmin, ServerAlias, ServerLimit, ServerName, ServerPath, ServerRoot, ServerSignature, ServerTokens, SetEnv, SetEnvIf, SetEnvIfNoCase, SetHandler, SetInputFilter, SetOutputFilter, StartServers, StartThreads, Substitute, SuexecUserGroup, ThreadLimit, ThreadStackSize, ThreadsPerChild, TimeOut, Timeout, TraceEnable, TransferLog, TypeAuthDBMUserFile, TypesConfig, UnsetEnv, UseCanonicalName, UseCanonicalPhysicalPort, User, UserDir, VirtualDocumentRoot, VirtualDocumentRootIP, VirtualHost, VirtualScriptAlias, VirtualScriptAliasIP, Win32DisableAcceptEx, XBitHack, allow, deny, order, php_admin_flag, php_admin_value, php_flag, php_value</p>
<p class="anote">You can view the <a href="http://www.askapache.com/htaccess/htaccess-security-block-spam-hackers.html">plugins home page</a>, <a href="http://www.askapache.com/wordpress/htaccess-password-protect.html#aadl">old</a>, or <a href="http://wordpress.org/extend/plugins/askapache-password-protect/" rel="nofollow" >view it on the wordpress.org site</a>.</p>
<p><a href="http://www.askapache.com/wordpress/an-askapache-plugin-upgrade-to-rule-them-all.html"></a><a href="http://www.askapache.com/wordpress/an-askapache-plugin-upgrade-to-rule-them-all.html">An AskApache Plugin Upgrade to Rule them All</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/wordpress/an-askapache-plugin-upgrade-to-rule-them-all.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DNS Round Robin Configuration using Rsync over SSH</title>
		<link>http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html</link>
		<comments>http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html#comments</comments>
		<pubDate>Tue, 14 Apr 2009 05:46:20 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[503]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[CNAME]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HostGator]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[Powweb]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[PS1]]></category>
		<category><![CDATA[Round Robin]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=2540</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html" id="id12"></a><strong>The goal is to add the HostGator server</strong> to be an exact mirror of the static.askapache.com domain, then to add that server as a 2nd A record to my DNS zone.  That way half the visitors to the size will be taking up resources and bandwidth on the <a href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=AskApache-rrdns">HostGator</a> server instead of mine.<br /><br /><strong>Round Robin A records</strong> in DNS are intended to evenly distribute queries between each host of the same name.  Using some tricks straight out of a hackers toolbox we can verify if the distribution is taking place.  (<a href="http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html#dns-robin-works">It is.</a>)  <br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p>My traffic is growing, alot, and I need to plan how I&#8217;m going to maintain scalability, high availability, and redundancy.   Scalability is an application&#8217;s ability to support a growing number of users. High availability can be defined as redundancy or speed.  I decided to setup <a href="#dns-robin-round" rel="nofollow" >Round Robin DNS</a> for <a href="http://static.askapache.com/" rel="nofollow" >static.askapache.com</a>, which is the &#8220;static&#8221; <a href="http://www.askapache.com/htaccess/apache-speed-subdomains.html">subdomain</a> of <a href="http://www.askapache.com/">AskApache</a> that serves all the static assets like images, javascript, css, etc.. (<em>BTW, the z stands for ZAP</em>)..  All I needed to attempt setting this up was another hosting account on a separate server.  I have hosting accounts with around 10 different companies from working with various clients over the years, like <a href="http://www.powweb.com/join/index.bml?AffID=582654" rel="nofollow" >Powweb</a> and I don&#8217;t use them because they suck in terms of the unix environment.  Many of these web hosts are actually very fast bandwidth-wise..</p>
<h2><a id="#round-robin-concept" name="#round-robin-concept"></a>Round Robin Concept</h2>
<p><a href="#" rel="nofollow" class="IFL" ><img src="http://uploads.askapache.com/2009/04/round-robin-dns.png" alt="Round Robin DNS" title="Round Robin DNS" width="396" height="335" class="size-full wp-image-2622" /></a><strong>A few months ago</strong> I was given a free hosting account on <a href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=AskApache-rrdns" rel="nofollow" >HostGator</a> to evaluate and tempt me away from DreamHost to become a Gator.  I get a lot of these types of offers from time to time from the smaller Web companies who read AskApache.. but when I noticed the SSH access was jailed and saw how restrictive the shell was I felt like I was on a windows box..  I want a shell, cpanel sucks.  I compile and run everything from the shell so thats was a deal-breaker and I sorta forgot all about it.</p>
<p><strong>The goal is to add the HostGator server</strong> to be an <a href="http://www.askapache.com/security/mirror-using-rsync-ssh.html">exact mirror</a> of the static.askapache.com domain, then to add that server as a 2nd A record to my DNS zone.  That way half the visitors to the size will be taking up resources and bandwidth on the <a href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=AskApache-rrdns" rel="nofollow" >HostGator</a> server instead of mine.</p>
<p><strong>Round Robin A records</strong> in DNS are intended to evenly distribute queries between each host of the same name.  Using some tricks straight out of a <a href="http://www.askapache.com/security/computer-security-toolbox-2.html">hackers toolbox</a> we can <a href="#dns-robin-works" rel="nofollow" >verify if the distribution</a> is taking place.  (<a href="#dns-robin-works" rel="nofollow" >It is.</a>)  <br class="C" /></p>
<h2><a id="#dns-robin-dns" name="#dns-robin-dns"></a>DNS &#8211; Domain Name System</h2>
<p>The Domain Name System is often analogized as a &#8220;phone book&#8221; for the Internet because it translates human-friendly computer hostnames into IP addresses. For example, <code>www.askapache.com</code> translates to <code>208.113.134.190</code>.  Every request for a human-friendly hostname first needs to be translated to the IP before the server can be queried.  Normally each hostname corresponds to exactly 1 IP address.  But in a Round Robin setup, the idea is to have the hostname correspond to multiple IP addresses, which are different servers that house the exact same content, resulting in some hosts requesting files from one server, and another host requesting files from the other server, resulting in less CPU resources and bandwidth.</p>
<p>Here is an the zone for <code>static.askapache.com</code> Round Robin records:</p>
<table summary="Round Robin DNS Records" id="ver-zebra">
<colgroup>
<col class="e" />
<col class="o" />
<col class="e" />
<col class="o" />
<col class="e" /></colgroup>
<thead>
<tr>
<th scope="col" class="e">QUERY</th>
<th scope="col" class="o">TTL</th>
<th scope="col" class="e">CLASS</th>
<th scope="col" class="o">TYPE</th>
<th scope="col" class="e">ANSWER</th>
</tr>
</thead>
<tbody>
<tr>
<td>static.askapache.com</td>
<td>13084</td>
<td>IN</td>
<td>A</td>
<td>64.111.114.111</td>
</tr>
<tr>
<td>static.askapache.com</td>
<td>13084</td>
<td>IN</td>
<td>A</td>
<td>69.56.174.114</td>
</tr>
</tbody>
</table>
<h2><a id="#dns-robin-round" name="#dns-robin-round"></a>Round Robin DNS</h2>
<p>Round robin DNS is a technique of load distribution, load balancing, or fault-tolerance provisioning multiple, redundant Internet Protocol service hosts, e.g., Web servers, FTP servers, by managing the Domain Name System&#8217;s (DNS) responses to address requests from client computers according to an appropriate statistical model.</p>
<p>In its simplest implementation Round-robin DNS works by responding to DNS requests not only with a single IP address, but a list of IP addresses of several servers that host identical services. The order in which IP addresses from the list are returned is the basis for the term round robin. With each DNS response, the IP address sequence in the list is permuted. Usually, basic IP clients attempt connections with the first address returned from a DNS query so that on different connection attempts clients would receive service from different providers, thus distributing the overall load among servers.</p>
<p>Round robin DNS is often used for balancing the load of geographically-distributed Web servers. For example, a company has one domain name and three identical web sites residing on three servers with three different IP addresses. When one user accesses the home page it will be sent to the first IP address. The second user who accesses the home page will be sent to the next IP address, and the third user will be sent to the third IP address. In each case, once the IP address is given out, it goes to the end of the list. The fourth user, therefore, will be sent to the first IP address, and so forth.</p>
<p>Although easy to implement, round robin DNS has problematic drawbacks, such as those arising from record caching in the DNS hierarchy itself, as well as client-side address caching and reuse, the combination of which can be difficult to manage. Round robin DNS should not solely be relied upon for service availability. If a service at one of the addresses in the list fails, the DNS will continue to hand out that address and clients will still attempt to reach the inoperable service.</p>
<h2><a id="#dns-robin-works" name="#dns-robin-works" title="Efficacy of DNS Load Balancing"></a>Does Round Robin Work</h2>
<p>Definately.  I can look at the access logs for both servers and see that they are splitting the requests nicely.   It is definately not an exact split however, look at these statistics and you&#8217;ll see what I mean.</p>
<pre>$ dig @ns1.dreamhost.com +authority +all static.askapache.com
&nbsp;
;; ANSWER SECTION:
static.askapache.com.        14400   IN      A       69.56.174.114
static.askapache.com.        14400   IN      A       64.111.114.111
&nbsp;
$ dig @ns1.dreamhost.com +authority +all static.askapache.com
&nbsp;
;; ANSWER SECTION:
static.askapache.com.        14400   IN      A       64.111.114.111
static.askapache.com.        14400   IN      A       69.56.174.114</pre>
<p>The effects of caching will distort the effectiveness of any IP address allocation algorithm unless a 0 TTL is used which has the effect of significantly increasing the load on the DNS (and is not always implemented consistently). In this case the cure may be worse than the disease Good news we have good load balancing on our web servers. Bad news we need 17 more DNS servers!. Intuitively, and without running any experiments to verify, we would suggest that given a normal TTL (12 hours or more) and ANY IP allocation algorithm other than a single static list, loads should be reasonably balanced .</p>
<p><strong>Full root server query</strong></p>
<pre>Tracing to static.askapache.com[a] via A.ROOT-SERVERS.NET, maximum of 3 retries
A.ROOT-SERVERS.NET [.] (198.41.0.4)
 |\___ L.GTLD-SERVERS.NET [com] (192.41.162.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ D.GTLD-SERVERS.NET [com] (192.31.80.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ J.GTLD-SERVERS.NET [com] (192.48.79.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ H.GTLD-SERVERS.NET [com] (192.54.112.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ E.GTLD-SERVERS.NET [com] (192.12.94.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ F.GTLD-SERVERS.NET [com] (192.35.51.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ I.GTLD-SERVERS.NET [com] (192.43.172.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ G.GTLD-SERVERS.NET [com] (192.42.93.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ B.GTLD-SERVERS.NET [com] (2001:0503:231d:0000:0000:0000:0002:0030) Not queried
 |\___ B.GTLD-SERVERS.NET [com] (192.33.14.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ A.GTLD-SERVERS.NET [com] (2001:0503:a83e:0000:0000:0000:0002:0030) Not queried
 |\___ A.GTLD-SERVERS.NET [com] (192.5.6.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ C.GTLD-SERVERS.NET [com] (192.26.92.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
 |\___ M.GTLD-SERVERS.NET [com] (192.55.83.30)
 |     |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
 |     |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
 |      \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
  \___ K.GTLD-SERVERS.NET [com] (192.52.178.30)
       |\___ ns3.dreamhost.com [askapache.com] (66.33.216.216) Got authoritative answer
       |\___ ns2.dreamhost.com [askapache.com] (208.96.10.221)
        \___ ns1.dreamhost.com [askapache.com] (66.33.206.206) Got authoritative answer
&nbsp;
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 64.111.114.111
  ns1.dreamhost.com (66.33.206.206)       static.askapache.com -&gt; 69.56.174.114
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 64.111.114.111
  ns3.dreamhost.com (66.33.216.216)       static.askapache.com -&gt; 69.56.174.114</pre>
<h2><a id="#dns-online-tools" name="#dns-online-tools"></a>Live Online DNS Tools</h2>
<ul>
<li><a href="http://member.dnsstuff.com/amember/go.php?r=323972&#038;i=l0" rel="nofollow" >DNSstuff.com &#8211; Your Destination for DNS and Networking Tools</a></li>
<li><a href="http://www.zonecheck.fr/cgi-bin/zc.cgi?zone=askapache.com&#038;ns0=ns1.dreamhost.com&#038;ips0=&#038;ns1=ns2.dreamhost.com&#038;ips1=&#038;ns2=ns3.dreamhost.com&#038;ips2=&#038;ns3=&#038;ips3=&#038;ns4=&#038;ips4=&#038;ns5=&#038;ips5=&#038;ns6=&#038;ips6=&#038;ns7=&#038;ips7=&#038;intro=t&#038;explain=t&#038;details=t&#038;progress=counter&#038;report=byseverity&#038;format=html&#038;lang=en&#038;errorlvl=allwarning&#038;profile=automatic&#038;chkmail=t&#038;chkzone=t&#038;chkrir=t&#038;transp3=ipv4&#038;transp3=ipv6&#038;transp4=std" rel="nofollow" >ZoneCheck</a></li>
<li><a href="http://pingability.com/zoneinfo.jsp?domain=askapache.com" rel="nofollow" >Quick Check &#8211; Pingability.com</a></li>
<li><a href="http://www.squish.net/dnscheck/dnscheck.cgi?host=askapache.com&#038;type=ANY&#038;show_rootservers=on&#038;removebroken=on&#038;cnameprocessing=on&#038;show_mainworkings=on&#038;show_resolving=on&#038;show_allservers=on&#038;getbindversions=on&#038;retries=5&#038;querylevel=15" rel="nofollow" >Squishywishywoo: complete dns traversal checking</a></li>
<li><a href="http://www.zonecut.net/dns/?domain=askapache.com&#038;find_subs=on" rel="nofollow" >ZoneCut DNS</a></li>
<li><a href="http://atrey.karlin.mff.cuni.cz/~mj/sleuth/?domain=askapache.com&#038;verbose=ON&#038;server=ns1.dreamhost.com&#038;serverip=&#038;action=Submit&#038;.cgifields=verbose" rel="nofollow" >DNS Sleuth</a></li>
<li><a href="http://www.pweb.cz/en/dns-test/dom.php" rel="nofollow" >DNS test &#8211; Domain name DNS test &#8211; pweb.cz</a></li>
<li><a href="http://www.opendns.com/support/cache/?d=static.askapache.com" rel="nofollow" >OpenDNS &#8211; Support &#8211; CacheCheck</a></li>
<li><a href="http://www.dnscolos.com/dnsreport.php" rel="nofollow" >DNSReport</a></li>
<li><a href="http://freedns.afraid.org/domain/dnstrace.php?domain=askapache.com&#038;submit=Trace" rel="nofollow" >DNSTrace</a></li>
<li><a href="http://www.intodns.com/askapache.com" rel="nofollow" >intoDNS</a></li>
<li><a href="http://www.dnsthru.com/" rel="nofollow" >DNSthru.com</a></li>
<li><a href="http://demo.dnsdoctor.org/cgi-bin/diagnose.cgi?zone=askapache.com&#038;ns0=ns1.dreamhost.com&#038;ips0=&#038;ns1=ns2.dreamhost.com&#038;ips1=&#038;ns2=ns3.dreamhost.com&#038;ips2=&#038;ns3=&#038;ips3=&#038;ns4=&#038;ips4=67.19.1.10&#038;ns5=&#038;ips5=67.19.0.10&#038;ns6=&#038;ips6=67.18.150.114&#038;ns7=&#038;ips7=&#038;intro=t&#038;format=html&#038;lang=en&#038;testname=t&#038;explain=t&#038;details=t&#038;progress=testdesc&#038;errorlvl=allwarning&#038;dontstop=nostop&#038;profile=automatic&#038;report=byseverity&#038;chkmail=t&#038;transp3=ipv4&#038;transp3=ipv6&#038;transp4=std" rel="nofollow" >DNS Doctor</a></li>
<li><a href="http://www.checkdns.net/powercheck.aspx" rel="nofollow" >Power Check</a></li>
</ul>
<h2><a id="#dns-links" name="#dns-links"></a>More Reading</h2>
<ul>
<li><a href="http://www.zytrax.com/books/dns/ch9/rr.html" rel="nofollow" >HOWTO &#8211; Configure Load Balancing</a></li>
<li><a href="http://ntrg.cs.tcd.ie/undergrad/4ba2.01/group8/DNS.html" rel="nofollow" >Load Sharing with DNS</a></li>
</ul>
<h3><a id="#dns-rfc-list" name="#dns-rfc-list"></a>RFC&#8217;s related to DNS</h3>
<ul>
<li><a href="http://rfc.askapache.com/rfc920/rfc920.html" rel="nofollow"  title="protocol,signature,resource,dnssec,records,response,record,dnskey,algorithm,standards,domain,server,resolver,security">RFC 920</a>:  Specified original TLDs: .arpa, .com, .edu, .org, .gov, .mil and two-character country codes</li>
<li><a href="http://rfc.askapache.com/rfc1032/rfc1032.html" rel="nofollow" >RFC 1032</a>:  Domain administrators guide</li>
<li><a href="http://rfc.askapache.com/rfc1033/rfc1033.html" rel="nofollow" >RFC 1033</a>:  Domain administrators operations guide</li>
<li><a href="http://rfc.askapache.com/rfc1034/rfc1034.html" rel="nofollow" >RFC 1034</a>:  Domain Names &#8211; Concepts and Facilities.</li>
<li><a href="http://rfc.askapache.com/rfc1035/rfc1035.html" rel="nofollow" >RFC 1035</a>:  Domain Names &#8211; Implementation and Specification</li>
<li><a href="http://rfc.askapache.com/rfc1101/rfc1101.html" rel="nofollow" >RFC 1101</a>:  DNS Encodings of Network Names and Other Types</li>
<li><a href="http://rfc.askapache.com/rfc1123/rfc1123.html" rel="nofollow" >RFC 1123</a>:  Requirements for Internet Hosts &#8212; Application and Support</li>
<li><a href="http://rfc.askapache.com/rfc1912/rfc1912.html" rel="nofollow" >RFC 1912</a>:  Common DNS Operational and Configuration Errors</li>
<li><a href="http://rfc.askapache.com/rfc1995/rfc1995.html" rel="nofollow" >RFC 1995</a>:  Incremental Zone Transfer in DNS</li>
<li><a href="http://rfc.askapache.com/rfc1996/rfc1996.html" rel="nofollow" >RFC 1996</a>:  A Mechanism for Prompt Notification of Zone Changes (DNS NOTIFY)</li>
<li><a href="http://rfc.askapache.com/rfc2136/rfc2136.html" rel="nofollow" >RFC 2136</a>:  Dynamic Updates in the domain name system (DNS UPDATE)</li>
<li><a href="http://rfc.askapache.com/rfc2181/rfc2181.html" rel="nofollow" >RFC 2181</a>:  Clarifications to the DNS Specification</li>
<li><a href="http://rfc.askapache.com/rfc2182/rfc2182.html" rel="nofollow" >RFC 2182</a>:  Selection and Operation of Secondary DNS Servers</li>
<li><a href="http://rfc.askapache.com/rfc2308/rfc2308.html" rel="nofollow" >RFC 2308</a>:  Negative Caching of DNS Queries (DNS NCACHE)</li>
<li><a href="http://rfc.askapache.com/rfc2317/rfc2317.html" rel="nofollow" >RFC 2317</a>:  Classless IN-ADDR.ARPA delegation</li>
<li><a href="http://rfc.askapache.com/rfc2671/rfc2671.html" rel="nofollow" >RFC 2671</a>:  Extension Mechanisms for DNS (EDNS0)</li>
<li><a href="http://rfc.askapache.com/rfc3597/rfc3597.html" rel="nofollow" >RFC 3597</a>:  Handling of Unknown DNS Resource Record (RR) Types</li>
<li><a href="http://rfc.askapache.com/rfc3696/rfc3696.html" rel="nofollow" >RFC 3696</a>:  Application Techniques for Checking and Transformation of Names</li>
<li><a href="http://rfc.askapache.com/rfc4343/rfc4343.html" rel="nofollow" >RFC 4343</a>:  Domain Name System (DNS) Case Insensitivity Clarification</li>
<li><a href="http://rfc.askapache.com/rfc4592/rfc4592.html" rel="nofollow" >RFC 4592</a>:  The Role of Wildcards in the Domain Name System</li>
<li><a href="http://rfc.askapache.com/rfc4892/rfc4892.html" rel="nofollow" >RFC 4892</a>:  Requirements for a Mechanism Identifying a Name Server Instance</li>
<li><a href="http://rfc.askapache.com/rfc5001/rfc5001.html" rel="nofollow" >RFC 5001</a>:  DNS Name Server Identifier Option (NSID)</li>
<li>RFC 5395:  Domain Name System (DNS) IANA Considerations</li>
</ul>
<p class="wikicop">This page contains content by <a href="http://en.wikipedia.org/w/index.php?title=Round_robin_DNS&#038;action=history"rel="nofollow" >Author</a> of <a href="http://en.wikipedia.org/wiki/Round_robin_DNS" rel="nofollow">Article</a> from <a href="http://en.wikipedia.org/wiki/Main_Page" rel="nofollow">Wikipedia</a> and is licensed under the <a href="http://www.askapache.com/gnu-fdl.txt" rel="nofollow">GNU FDL</a>.</p>
<p><strong>Table of Contents</strong></p>
<ul>
<li><a href="#round-robin-concept" rel="nofollow" >Round Robin Concept</a></li>
<li><a href="#dns-robin-dns" rel="nofollow" >DNS &#8211; Domain Name System</a></li>
<li><a href="#dns-robin-round" rel="nofollow" >Round Robin DNS</a></li>
<li><a href="#dns-robin-works" rel="nofollow" >Efficacy of DNS Load Balancing</a></li>
<li><a href="#dns-online-tools" rel="nofollow" >Live Online DNS Tools</a></li>
<li><a href="#dns-links" rel="nofollow" >More Reading</a></li>
<li><a href="#dns-rfc-list" rel="nofollow" >RFC&#8217;s related to DNS</a></li>
</ul>
<p><a href="http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html"></a><a href="http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html">DNS Round Robin Configuration using Rsync over SSH</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux-unix/dns-round-robin-rsync-over-ssh.html/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
