These are a few of the mod_rewrite uses that BlogSecurity declared pushed the boundaries of Mod_Rewrite! Some of these snippets are quite exotic and unlike anything you may have seen before, also only for those who understand them as they can kill a website pretty quick.
Htaccess Htaccess mod_rewrite RewriteCond RewriteRule wordpress
If you want to redirect to a different version of a file based on the time, this code is for you! Please read: Serve Alternate Content based on Time
Htaccess
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.
PHP
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!
Htaccess Header Htaccess
Unix file permissions are one of the more difficult subjects to grasp.. Well, ok maybe "grasp" isn't the word.. Master is the right word.. Unix file permissions is a hard topic to fully master, mainly I think because there aren't many instances when a computer user encounters them seriously, and bitwise is oldschool. This contains a listing of all possible permission masks and bits from a linux, php, and web hosting view.... cuz you guys AskApache Regs Rock!
Security chmod File Permissions umask
WordPress robots.txt file can make a huge impact on your WordPress blogs traffic and search engine rank. This is an SEO optimized robots.txt file. SEO robots.txt
Before
init-connect='SET NAMES utf8'
init_connect='SET CHARACTER SET=utf-8'
After
init_connect='SET collation_connection = utf8_general_ci,NAMES utf8'
MySQL init-connect my.cnf utf8
Ok, so on a site like this one, there is a tremendous amount of 'code' styled with CSS fonts in a pre, code, var, tt, samp, or kbd html tag. When using an programming tool like VIM to write code it is shown beautifully using your OS fonts. So then, how can we get that same font beauty to be there on the web? And, of course the solution must use best-practices (and preferably only use CSS and (X)HTML).
Also, text effects! --> View Solution
CSS font Google
Securing Subdirectories using unique apache htaccess solutions.
Htaccess
Its really nice to be able to print out a webpage you are reading using your browsers built-in print feature. Using CSS you can easily transform your site into a print-friendly site.
Today I received an email from a visitor to my site requesting that I add a way to print site articles on AskApache
CSS Cascading Style Sheets nicer printing Style sheet
If you are using Disqus on your site, you will see that annoyingly the default sort order for listing comments is 'best'.
I have implemented disqus on many sites and the number 1 request I get is to change the default sort order to newest.
There is no documentation or hints anywhere to solve this. So I solved it.
Javascript Disqus
CURL Guide for sending POST data form request with PHP and CURL
PHP
Control htaccess Basic Authentication with PHP and mod_rewrite Htaccess
Find and Replace tool in Adobe DreamWeaver is useful of course, but you aren't using a fraction of the power until you use REGEX.
Software
I looked at a lot of different ways to display quotes and pullquotes and even though the javascript solutions are very nice, esp. the 456bereastreet.com solution, I decided to just use CSS (Keep It Simple Stupid).
CSS
Files that can be deleted after installing wordpress
- license.txt
- Readme.html
- the import*.php files
WordPress
Apache Web Server users have problems getting Apache Authentication/password-protection in htaccess working, this is a troubleshooting guide to get Password Protection working!
Htaccess
Nifty SEO tip to get Search Engine Bots to check your site every hour until you finish working on it and tell them you are finished.
SEO
Wouldn't it be great if you could use php and curl to download multiple files simultaneously using built-in curl functions? You can!
PHP
Request to https://www.askapache.com/cg/rewrite-test/?catch=caught&this=that
RewriteCond %{THE_REQUEST} = GET /cgi-bin/php/pro/rewrite-test/?catch=caught&this=that HTTP/1.1
RewriteCond %{REQUEST_URI} = /cg/rewrite-test/?catch=caught&this=that
RewriteCond %{QUERY_STRING} = catch=caught&this=that
RewriteCond %{HTTP_HOST} = www.askapache.com
RewriteCond %{HTTP_USER_AGENT} = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
RewriteCond %{REMOTE_ADDR} = 8.8.8.8
Htaccess
Use mod_rewrite to enable phpMyAdmin links in the form: /dbname/table/
Htaccess phpMyAdmin RewriteRule
Fighting Blog Spam with Apache htaccess and other methods.
Htaccess
One of the most cost-effective ways to drive traffic to your Web site is to optimize it for search engines. Many of them use automated programs called "crawlers" or "spiders" to create an index of the Web, which they use to determine what sites are most relevant to users' queries. These programs essentially visit Web sites, read the pages' content, and follow any links to other pages, repeating the process
SEO
I hope this will pursuade you to stop using PHP short_open_tag syntax.
<?= or <?
PHP PEAR wordpress
Use the Apache module mod_deflate to compress your static .css and .js files, speeding your site up like crazy!
Htaccess compression Htaccess mod_deflate mod_gzip SetOutputFilter
Learn how to make YOUR DreamHost promo codes work much better for YOU! This is not about promo-codes, this is about a simple method you should implement.
Hosting
The bottom line for this article is that I want to make WordPress as fast, secure, and easy to install, run, and manage because I am using it more and more for client production sites, I will work for days in order to solve an issue so that I never have to spend time on that issue again. Time is money in this industry and that is ultimately (time) what there is to gain by tweaking WordPress.
Note: I spent no time on readability, this is primarily a read the code and figure it out article.. This is for advanced users looking for a reference or discussion and for those of you looking to advance. Feedback would be great if you make it that far..
WordPress wordpress wp-config.php
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 nice and renice, and other tools like ionice 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.
Optimization CFQ Idle linux Linux scheduler Load Nice RAM Scheduling algorithms
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.
Htaccess Cache-Control ETags
Using a CSS Background Image Sprite with the CSS background-position and background-image I can display all these icons: . I can even have them show up anywhere on the page!
CSS
The secrets in this post were really more of enlightening bits of seo wisdom. The secret is how to combine robots.txt with meta robots tags to control pagerank, juice, whatever.
SEO
Just a very brief look at speeding up form submission by delegating the processing and bandwidth to your server, not your client.
PHP bottleneck cURL form fsockopen PHP snoopy
PHP's fsockopen function lets you open an Internet or Unix domain socket connection for connecting to a resource, and is one of the most powerful functions available in the php language.
PHP fsockopen PHP socket strace udp Unix

Well what can I say, other than this is sooo DOPE! Here is a list of the modules this plugin (version 4.7 unreleased) will automatically detect. I compiled the list myself using every module included with any default Apache installation for ALL the versions listed below, 1.3 to 2.2+
Want to know something else I'm including in this plugin? For each and every module that is detected, this plugin can then detect ALL of the modules .htaccess Directives! For instance, RewriteRule, AccessFileName, AddHandler, etc.. are each a directive belonging to a module that is allowed to be used from within .htaccess files.
Talk about sick.. these tricks have the diamond disease!
WordPress Advanced Anti-Exploit Anti-Spam Htaccess RewriteCond RewriteRule security SSL THE_REQUEST
Check out this free online SEO site-scoring tool. The SEO generated report is simple, neat, and helpful. The main thing I like about it is how it is a stand-alone website, a residual money making machine.
Software
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.
Htaccess Cache Caching ETag Htaccess Last-Modified
Want to block a bad robot or web scraper using .htaccess files? Here are 2 methods that illustrate blocking 436 various user-agents.
Htaccess