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 say sorry about that, and thanks for all the great ideas.. 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 time to jam.
Tagged: AskApache Google 404, AskApache Password Protection, Fsockopen, WordPress Plugins, wordpress security | 1 Comment | Continue...
This is not an introduction to .htaccess… This is the evolution of .htaccess… The BEST, the ORIGINAL, the NEWEST, and the most HIGHEST, FLYEST .htaccess tricks I can find.
Originally known as the “Ultimate .htaccess Guide”, its changed over the years by adding new .htaccess tricks and .htaccess examples to it.. I also add my favorite .htaccess links, the best .htaccess articles on AskApache, the coolest .htaccess experiments, the Web’s best .htaccess hacks, and update this article on the regular.
Tagged: .htaccess examples, Apache, Cache, caching, Files, FilesMatch, Google, Hacking, howto, htaccess, htaccess guide, htaccess help, htaccess howto, htaccess rewrite, htaccess tricks, htaccess tutorial, httpd, litespeed, mod_rewrite, Mod_Security, rewritecond, rewriterule, sample .htaccess, Security, SEO, seo secrets, SetEnvIf, ssl, ultimate htaccess | 56 Comments | Continue...
This past week I updated my sites apache.css file for a site-redesign. I wanted to make changes to the .css file that only I could see, so that my regular traffic and site-visitors would still see the old version. Here’s the elegant solution I came up with using .htaccess and mod_rewrite that works so well I’m sharing it with all you wonderful and incredible people reading my blog :)
Tagged: CSS, htaccess, mod_rewrite, trick, tutorial | 4 Comments | Continue...
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.
Tagged: Apache, Cache, compression, hosting, htaccess, optimization, Security, server | 5 Comments | Continue...
I’ve had a lot of people ask about the FeedBurner FeedCount image on AskApache. Specifically how to set it up with custom messages and different colors each page view… It is pretty sweet..
Tagged: feed, FeedBurner, FeedCount, htaccess | Continue...
thought I’d take a break from coding and post about how open-source is such a great tool for finding the best answers to the toughest questions,
/** is the status code informational */ #define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) /** is the status code OK ?*/ #define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) /** is the status code a redirect */ #define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) /** is the status code a error (client or server) */ #define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) /** is the status code a client error */ #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) /** is the status code a server error */ #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) /** is the status code a (potentially) valid response code? */ #define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((x) < 600))
Tagged: httpd.conf, source code | Continue...
If you want to pre-load .flv / .mp3 files into a visitors browser cache using flash, here’s the actionscript I use to do it, and some ideas behind a good javascript implementation using swfobject or ufo.
Tagged: actionscript, htaccess, Javascript, preloading | 9 Comments | Continue...
Mod_Security rivals Mod_Rewrite in the amount of features it provides. I decided to go ahead and post what I learned about it today, even though its tough to give away such awesome htaccess and apache tricks.. Learn how to control spam once and for all, conditionally log/deny/allow/redirect requests based on IP, username, etc.. Mod_Security is so fine!
Tagged: Hacking, htaccess, Mod_Security, Security | 8 Comments | Continue...
htaccess rewrite / Mod_Rewrite Tips and Tricks is as glamorous as it sounds! htaccess rewrite mod_rewrite is just possibly one of the most useful Apache modules and features. The ability to rewrite requests internally as well as externally is extremely powerful.
Tagged: htaccess, htaccess rewrite, mod_rewrite, Redirecting URLS, rewrite, Rewrite Tricks, rewritecond, rewriterule | 57 Comments | Continue...
A WordPress plugin that caches your entire blog for WP-Cache, I love this plugin and finally released it to the public!
This article shows how to save and modify php session data, cookies, do anything really… without using ajax or iframes or forcing the user make a request.
Tagged: Cookies, PHP, Sessions | 2 Comments | Continue...
Learn about the 7 different HTTP response codes specifically reserved for redirection. 301, 302, 303, 304, 305, and 307.
Tagged: experiments, http, redirection, robots.txt | 2 Comments | Continue...
If you desire SPEED from your WordPress blog, the #1 speed improvement comes from using the WP-Cache Plugin. If you still desire SPEED after installing the Plugin, you can modify the WP-Cache Plugin code to make your blog even faster!
Using Cache-Control headers you can specify which types of proxies can cache certain content, and how long files should be cached.
Tagged: Cache, Headers, htaccess, optimization | 6 Comments | Continue...
How I was able to preload many flash flv and swf files on one of my clients sites that has a lot of online video and relatively small traffic. Their site visitors would usually watch 3-10 videos per visit and so to make the videos load almost instantly on every page I came up with a way to preload the top 10 .flv files and the swf flv player files as soon as the visitor successfully started watching the 1st video. Of course I also setup .htaccess caching on the server so that once they downloaded the files into their cache they would never request them from the server again. I was having fun with this so its pretty funky and uses some really cool combinations of javascript, swf preloader from xml, css classes to help automate it all..
Tagged: Cache, Flash, preload | 4 Comments | Continue...
Host Google Analytics ga.js file locally for increased speed! Makes web pages load faster.
If you have a Powweb Webhosting account, you will appreciate this simple skeleton .htaccess file for use on their systems.
SetEnv, SetEnvIf, and SetEnvIfNoCase directives conditionally set environment variables accessible by scripts and apache based on HTTP Headers, Variables, and Request information.
Tagged: Examples, htaccess, mod_rewrite, mod_setenvif, SetEnv, SetEnvIf | 4 Comments | Continue...
Apache .htaccess Directives and Loaded Modules allowed on DreamHost Apache Server 2 Setups.
HTTP Headers
HTTP Header Name
Header Description
Example HTTP Header
Accept
Content-Types that are acceptable
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Charset
Character sets that are acceptable
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding
Acceptable encodings
Accept-Encoding: gzip,deflate
Accept-Language
Acceptable languages for response
Accept-Language: en-us,en
Accept-Ranges
What partial content range types this server supports
Accept-Ranges: bytes
Age
The age the object has been in a proxy cache in seconds
Age: 7200
Allow
Valid actions for a specified resource. To be used for a 405 Method not allowed
Allow: GET,HEAD,POST,OPTIONS,TRACE
Authorization
Authentication credentials for HTTP authentication
Authorization: Basic UXNrYXBhggRfoopc5NteWFzcw==
Cache-Control
Controls how proxies may cache this object
Cache-Control: max-age=7200, public
Connection
What type of connection the user-agent would prefer
Connection: Keep-Alive
Content-Encoding
The type of encoding used on the data
Content-Encoding: gzip
Content-Language
The language the content is in
Content-Language: en-us
Content-Length
The length of the content in bytes
Content-Length: 5356
Content-Location
An alternate location for the returned data
Content-Location: /index.html
Content-MD5
An MD5 sum of the content of the response
Content-MD5: 1167b9c13ad2b6d3694493fc47976c8
Content-Range
Where in a full body message this partial message belongs
Content-Range: bytes 110-2034/2035
Content-Type
The mime type of this content
Content-Type: text/html; charset=UTF-8
Date
The date and time that the message was sent
Date: Sat, 05 Jan 2008 09:27:35 GMT
Host
The domain name of the server (for virtual hosting)
Host: www.askapache.com
If-Modified-Since
Allows a 304 Not Modified to be returned
If-Modified-Since: Sat, 05 Jan 2007 09:26:12 GMT
Last-Modified
The last modified date for the requested object
Last-Modified: Sat, 05 Jan 2008 09:26:12 GMT
Location
Used in redirection
Location: http://www.askapache.com/
Server
A name for the server
Server: 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 SVN/1.4.2
User-Agent
The user agent string of the user agent
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
List of HTTP Response Status Codes
1xx Info / Informational
HTTP_INFO – Request received, continuing process.
Indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
100 Continue – HTTP_CONTINUE
101 Switching Protocols – HTTP_SWITCHING_PROTOCOLS
102 Processing – HTTP_PROCESSING
2xx Success / OK
HTTP_SUCCESS – The action was successfully received, understood, and accepted.
Indicates that the client’s request was successfully received, understood, and accepted.
200 OK – HTTP_OK
201 Created – HTTP_CREATED
202 Accepted – HTTP_ACCEPTED
203 Non-Authoritative Information – HTTP_NON_AUTHORITATIVE
204 No Content – HTTP_NO_CONTENT
205 Reset Content – HTTP_RESET_CONTENT
206 Partial…
To make your site even faster, serve certain content from different subdomains. The reason this works is amazingly cool!
Update: This article is a bit dated, to get the newest and latest Google Analytics Speed Tips, check out the 3 part update about Hosting, Cookie Domains, and JavaScript Loading and Failproofs
Ever notice that sometimes your sites take a while to load all the way because google’s urchin.js file is taking forever? You may recognize this problem when you see something similar to this in your browsers status bar “Transferring data from google-analytics.com…”
Time To Setup?
4 minutes I got tired of seeing that all the time and so I set up an automated cronjob that runs every 12 hours and downloads the latest version from google, and saves it to my website directory, then I reference /urchin.js instead of http://www.google-analytics.com/urchin.js.. and my site loads a lot faster!
Take a look at the source for this page if you want to see what is going on (look at the bottom)
There are 2 pretty major things that you accomplish by hosting urchin.js locally
You Enable persistant connections
You ensure that the correct 304 Not Modified header is sent back to your site visitors instead of reserving the entire file.
The urch.sh shell script
Create a shell script called urch.sh.. this will be executed every 1/day or 1/wk, whatever you want. The following script removes the local urchin.js, then it wgets the latests version into the local directory.
#!/bin/sh
rm /home/user/websites/askapache.com/z/j/urchin.js
cd /home/user/websites/askapache.com/z/j/
wget http://www.google-analytics.com/urchin.js
chmod 644 /home/user/websites/askapache.com/z/j/urchin.js
cd ${OLDPWD}
exit 0;
Improved shell script
I realized right away that a more modular shell script would be needed.. I admin like 50+ web-sites and it would be stupid to have to type the same block of code 50 times, wget the same file 50 times, etc.. So this version downloads the urchin.js file into a temporary directory, then it copies it OVER the old file for each directory. So 1 GET request…
Tagged: Google Analytics, urchin.js | 11 Comments | Continue...
If you remove the Last-Modified and ETag header, you will totally eliminate If-Modified-Since and If-None-Match requests and their 304 Not Modified Responses.
Tagged: Cache, etag, Headers, htaccess, http, Last-Modified | 6 Comments | Continue...
By removing the ETag header, you disable caches and browsers from being able to validate files, so they are forced to rely on your Cache-Control and Expires header.
Tagged: Cache, Cache Validation, Etags, optimization, YSlow | 8 Comments | Continue...
A first-time visitor to your page will make several HTTP requests to download all your sites files, but using the Expires header you make those files cacheable. This avoids unnecessary HTTP requests on subsequent page views.
Tagged: Headers, htaccess, optimization, YSlow | 7 Comments | Continue...
Use the Apache module mod_deflate to compress your static .css and .js files, speeding your site up like crazy!
Tagged: Cache, caching, etag, expires header | 16 Comments | Continue...
High Performance Web Site list of the best and newest methods to make web pages super fast using caching, compression, cache-control, etc.
Server and Environment Variables are used by The Apache HTTP Server by provides a mechanism for storing information. This information can be used to control various operations such as logging or access control.
Apache has the best SSL/HTTPS support and can be controlled by the httpd.conf file or other HTTPD server configuration file. This htaccess tutorial has htaccess example code to make it easy to secure and use HTTPS and SSL with Apache.
Apache Security tips and tricks for securing Apache Web Servers using htaccess, httpd.conf, and other built-in techniques to thwart attackers. This really should be required reading for any Apache admin or user because these little tricks are so easy to do.
Tagged: Hacking, htaccess, mod_python, Security | 2 Comments | Continue...
How to password-protect, Allow or Deny a visitor based on a condition. If you are having trouble getting htaccess-based password protection to work see: Troubleshooting htaccess Authentication: Getting it to work
Caching with .htaccess and Apache will take your website and your web skills to the next level. This is some technical and advanced methods condensed to simple htaccess code examples for you.
Web Professionals use mod_rewrite to issue 301 and 302 Redirects for Search Engines. Sometimes you may not have mod_rewrite.c or you want an alternative redirect method. Using mod_alias RedirectMatch you can use REGEX in Redirect commands!
Tagged: htaccess, ultimate htaccess | 11 Comments | Continue...
Htaccess php tips and tricks for the Apache HTTPD Web Server, mostly these tips show you how to run customized versions with customized php.ini files, I require custom php.ini files because they are so useful!
Apache .htaccess and httpd.conf have the power to send and manipulate HTTP Header Requests like sending P3P privacy headers, Content-Type: UTF-8, Content-Language, etc. The power is immense and you can do some really cool stuff with HTTP Headers!
Some of my favorite htaccess examples from some of my favorite .htaccess tutorials. These cut-and-paste ready htaccess code snippets are very useful for website and server administrators.
Tagged: htaccess, htaccess tricks | 9 Comments | Continue...
Comprehensive .htaccess example file with advanced examples in 1 htaccess sample skeleton .htaccess file with the very best apache htaccess examples… Updated frequently based on detailed info from the Apache htaccess tutorial.
Apache server performance can be improved by adding additional hardware resources such as RAM, faster CPU, etc.
This article is a quick and easy HowTo detailing the use of Wireshark or another network sniffing program to debug your Apache .htaccess or httpd.conf files.
If you examine the preferences dialog of any modern Web browser (like Internet Explorer, Safari or Mozilla), you’ll probably notice a ‘cache’ setting. This lets you set aside a section of your computer’s hard disk to store representations that you’ve seen, just for you. The browser cache works according to fairly simple rules. It will check to make sure that the representations are fresh, usually once a session (that is, the once in the current invocation of the browser).
The love of liberty is the love of others; the love of power is the love of ourselves.
-- William Hazlitt
Please consider donating to support active development of the free software and articles here.![]()
The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee
It's very simple - you read the protocol and write the code. -Bill Joy
HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C | TLDP | WAI | DISA | ICSI | GIAC | SANS RR | GHOST | DEFCON | NIST | DHS CYBER | NIST | Phrack | GDB | IEEE | GIT | GNU LIBC
↑ TOPExcept where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. HTTPD based on NCSA HTTPd