htaccess

Preventing direct access to hidden files and folders

Hidden files and folders usually contain configuration data and other goodies not intended for public consumption. Git, for example, saves all sorts of useful information in a root-level directory named .git. By default these files and folders don’t appear in a directory listing, but depending on server setup and where they live relative to the […]

Redirecting http to https with htaccess

Once a site has been transitioned to the https protocol, it’s important to redirect all legacy traffic through this protocol, with a 301 “permanently moved” status code, so the change can propagate fully. Otherwise any site with a now-outdated a link to the http version will continue browsing that version, handily and unknowingly circumventing all […]

Case-insensitive RedirectMatch

RedirectMatch rules are, by default, case-sensitive: # ‘Old-Page.htm’ will result in a 404 error RedirectMatch 301 ^/old-page.htm$ http://new-site.com/ To make a RedirectMatch rule case-insensitive, add (?i) to the start of pattern: # Will redirect properly regardless of capitalization: RedirectMatch 301 ^(?i)/old-page.htm$ http://new-site.com/

WWW is dead. Long live WWW!

The discussion over whether one’s domain needs a “www” prefix is lively and on-going. Some are staunchly against; others are stubbornly in favor. (And no one can seem to resist borrowing from Hamlet.) Seeing I’m never as interested in what’s right as much as what works I present both methods and allow the reader to […]