A fresh mix of code snippets and tutorials

Category Archive: .htaccess

Posts about Apache and .htaccess

Page 4 of 4

Redirect URLs with .htaccess

Here is a quick cheat-sheet for redirecting URLs with .htaccess.

Maintenance mode via .htaccess

For WordPress users there are at least three great plugins that make maintenance mode just dead-simple. Even so, here is how to do it with .htaccess.

Canonical snippets for WordPress

.htaccess enables us to easily clean up 404 errors and other misdirected HTTP traffic for better SEO. Here are some canonical snippets for WordPress and beyond.

Redirect HTTP to PHP via .htaccess

Here is how to redirect specific URL requests to a PHP script for further processing, etc. Very useful for monitoring HTTP activity, logging errors, and more.

Redirect HTTP to HTTPS

In addition to www canonicalization, you can also canonicalize the HTTP protocol, redirecting HTTP to HTTPS (or vice versa) using Apache/.htaccess. Below you will find several ways to force SSL/TLS for all URI requests. This is especially useful for sites with existing links pointing to unencrypted http:// URLs. Enforcing use of SSL/HTTPS helps to eliminate […]

.htaccess for Apple Touch Icons

Devices and bots are often searching for different versions of the Apple Touch Icon. Here is a quick slice of .htaccess to redirect all apple-icon requests to apple.png.

Allow access to external IPs during development

When developing sites, an easy way to keep things private is to use .htaccess to restrict access based on IP address.

FeedBurner .htaccess redirect

Need to redirect your feeds to FeedBurner? Here’s how to do it with a thin slice of .htaccess.

Remove www and index.php from URL

Here’s a handy .htaccess snippet for canonicalizing URLs by removing the “www”, “index.php”, and “index.html” from all requests.

PHP trap for bad bots

Another effective trap for bad bots and spammers, built with PHP and a slice of .htaccess.

Block XSS with .htaccess

Quick snippet today that you can add to your .htaccess file to block some common XSS (cross-site scripting) attacks.