.htaccess Tutorials

  • By
    Quickly Set Up a Templating System Using .htaccess

    Setting up a website capable of easy template switching probably sounds difficult. When I first thought about building a templating system, it felt like a pretty daunting task. After tinkering around for a few days, I found a way that would allow me to...

  • By
    Check For Module Presence in .htaccess

    One of my favorite Apache modules is mod_rewrite. mod_rewrite allows me to manipulate page URLs so that I can search engine friendly URLs. Not every Apache server has the mod_rewrite module installed so you will want to add a conditional statement within your .htaccess...

  • By
    .htaccess “Down For Maintenance” Page Redirect

    I recently needed to move one website from a shared web host to our internal server. After some discussion, we decided to simply add a "Site Down For Maintenance" page to the site to prevent users from submitting orders during the hosting change. Using...

  • By
    Force Secure (SSL) Pages With .htaccess

    A while back, I shared a method for forcing a secure page using PHP. What if you want to force SSL (https://) on an entire website though? You don't want to have to put force-SSL PHP code on every page, right? Well...

  • By
    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...

  • By
    No WWW Using .htaccess

    There are some clear benefits to removing the "www" from your URLs: Shorter URLs Prevention of Google search engine penalties for duplicate content Less bandwidth usage if you have many links per page Luckily, removing the WWW from your page URLs (and subsequent Google listings) can be done inside your...

  • By
    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:Search engine friendly URLS and image names (for image searches)Descriptive file names give users a "preview" of the...

  • By
    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: The above .htaccess file code, placed on the old domain...

  • By
    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:Keeping a known hacker/bot from...

  • By
    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...