.htaccess Tutorials
Password Protect a Directory Using .htaccess
Protecting files on your website from unauthorized users can be very important. Even more important is the method by which you accomplish this task. You could use PHP to listen for login authorization information on each page, but that doesn't protect your images, documents, and other media, does it? That's why I've found the .htaccess method of protecting files and directories the most reliable. Oh, and it's easy too!
No WWW Using .htaccess
There are some clear benefits to removing the "www" from your URLs:
Organized, Short Folder Structure Using mod_rewrite
I tend to be over-organized when I create the folder structure of my customers' websites. I like using descriptive file and folder names for a number of reasons:
Change Domains But Keep Your Traffic – .htaccess 301s
Changing domains was a big decision. My biggest concern was being able to keep my user, RSS feed, and search engine traffic. Luckily, the power of the .htaccess file allowed me to do so:
Advanced .htaccess Security – Allow or Block Specific IPs From Your Website
The more I use the .htaccess file the more I appreciate its value. My next valuable lesson in .htaccess security deals with allowing and blocking access to a web server from a specific IP address. Reasons for doing this include:
Advanced .htaccess Security – Block Unwanted Referrers
For some bloggers and web developers, Digg can be a huge boost in traffic and thus a huge bust in ad revenue. Unfortunately, the Digg Effect can kill a website's bandwidth and get the website shut down. Wouldn't it be great if a weary web developer could prevent his site from being shut down by blocking users referred by Digg, at least a while? Using a small bit of .htaccess code and mod_rewrite, the developer can do just that.
Advanced .htaccess Security – Block Access to Include Files Using .htaccess
When I build websites for clients and myself, I use numerous include files to make my website easy to maintain. These include files may:
WordPress’ .htaccess File Is Genius
Choosing to use WordPress was a more difficult decision that you may think. Sure, WordPress is the most used blogging software on the internet, but I'm a programmer, right? I should want to code everything myself, right? I thought that at first but I decided to try WordPress first and I've been impressed with every part of WordPress so far. One of the interesting parts of WordPress is the URL rewriting and "slug" that gets created for each post. How did they do that?
Prevent Image Hotlinking With .htaccess and mod_rewrite
One way to kill your website's bandwidth and overall download speed is to not block image "hotlinking." What's hotlinking? Hotlinking is linking to a file on an external server that the Web Developer does not own (most of the time the Web Developer doesn't even have permission to use the file). Hot linking occurs mostly with images.
Advanced Branding – Give Your Pages A Custom Extension Using .htaccess SetHandler
A sign of a good website is one that does the "little things" to increase the usability or value to the user. There are other little things you can do to enhance your website, including giving your pages a custom extension.