Stop those hotlinking SOBs with .htaccess.

Stop those hotlinking SOBs with .htaccess.

Is your bandwidth meter spinning like a top, but your page views just aren’t where you think they should be for all that “traffic”? It’s possible that you, my friend, are a victim of bandwidth theft due to hotlinking. Hotlinkers are dirty SOBs who steal your bandwidth by streaming your graphics, videos and/or music files onto their web site(s) directly from yours. Luckily daddy has a relatively simple solution to fix all the badness for you.

While there are a few options you have when you want to deal with hotlinkers, I’m going to demonstrate the easiest and often best suited solution: displaying an alternate graphic instead of the one that the hotlinkers are stealing from your web site. If you’d like more options or want to do something different feel free to leave a comment below and I’ll answer as best as I can.

Now for the fun stuff. In the root of your blog’s web space, find and download (or create, if necessary) the .htaccess file. After you have a local version, copy and paste the following (and we’ll get into why some of the text is in bold in a moment) into the very beginning of the file:

.htaccess file

#   HOTLINK STOPPER
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bloglines\.com/ [NC]
RewriteRule .*\.(jpe?g|gif)$ http://yourothersite.com/hotlink.jpg [R,NC,L]

If you don’t copy+paste the text above into the beginning of your .htaccess file you may run into problems if you break something that already exists, so please use caution. Also, don’t let all the mumbo-jumbo scare you off. It’s pretty simple stuff. In fact, there are only six lines, and I’ll walk you through what each one does.

  1. # HOTLINK STOPPER

    This line is just a comment (delineated by the # at the beginning of the line) to let you know what this section of your .htaccess file is for. You can comment out any line by prepending it with a # symbol.

  2. RewriteEngine On

    Turns on the rewrite engine in Apache. Without this, none of the rest of the changes are necessary. Or possible.

  3. RewriteCond %{HTTP_REFERER} !^$

    Sets a condition for the rewrite engine to ignore anyone with a blank referer. Don’t worry about the !^$, it’s a regular expression, or “regex”, and it works when looking for a blank referer. And yes, that’s spelled correctly… for Internet purposes, anyhow. If you’re interested in the details, read up on how a referrer came to be a referer.

  4. RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]

    Sets a condition for the rewrite engine to ignore anyone that doesn’t have the domain example\.com in their referer. Replace the example portion with your blog’s domain name, but make sure that if you’ve got a .org blog that you keep the backslash in from of the period, otherwise the regex will break.

  5. RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bloglines\.com/ [NC]

    Sets a condition for the rewrite engine to ignore bloglines.com. This line is optional, but I kept it in this example since Bloglines is a pretty popular RSS reader, and you’re probably going to want your readers who use it to see the pictures on your server.

  6. RewriteRule .*\.(jpe?g|gif)$ http://yourothersite.com/hotlink.jpg [R,NC,L]

    Here’s where the fun begins. This line sets up a rule that will server any graphic (in this case a .jpg or .gif file) that is not ruled out from the conditions above to the file http://yourothersite.com/hotlink.jpg, thereby circumventing those damned, dirty apes hotlinkers. To add more file types, just add a pipe (“|”) character after gif and the extension (like a png) and you’re good to go.

    A word of caution: do not use a graphic that is on the domain that you are trying to dissuade hotlinkers from using as you’ll cause an infinite loop and in some cases may actually take down your own web server. I’ve seen it happen, and it ain’t pretty. I suggest you set up a free blog account somewhere, such as wordpress.com, and add your hotlink graphic there.

That’s pretty much it. All you have to do now is upload your new hotlink.jpg graphic and your .htaccess file and you’re good to go. If you’ve done everything right then the days of your bandwidth being stolen by hotlinkers should be coming to a close.

10 “Gotta Have” WordPress Plugins for Your Blog.

10 “Gotta Have” WordPress Plugins for Your Blog.

One of the quickest ways to make blogging easier on yourself is to use WordPress plugins. From automating tasks like backing up your blog articles to guarding your site from spam, plugins enhance your website and help you maintain a top notch blog. Luckily for us all, WordPress makes installing and using plugins as simple as a few button clicks.

There are literally thousands of plugins available, but the ones I’ve listed are ones I use over and over for many reasons. Some are optional depending on your level of blogging or code expertise (and will be noted in the descriptions below), but most of these plugins can be used on any blog to immediately improve things. If you have any questions, comments, or suggestions on plugins please leave me a comment below!

  1. Akismet:

    Akismet is a spam control plugin. Installed by default on all WordPress blogs, Akismet shouldn’t even be a question. It’s ridiculously accurate in separating spam from real comments and it just works.

  2. All in One SEO Pack:

    If you’re looking to increase the search engine friendliness of your site, start with this plugin. Coupled with some smart markup (read: HTML) and decent content, your blog will start seeing the love it deserves from Google, Bing, and other search engines. There are some great customization options available, too.

  3. Exec-PHP:

    In a nutshell, this WordPress plugin lets you add PHP code inside of posts. If you’re even slightly tech-minded, or if you want to add more functionality to your posts, the Exec-PHP plugin is a no brainer. If you don’t plan on using PHP I wouldn’t worry about this plugin; but if you do this is a must have.

  4. FD Feedburner Plugin:

    Get your RSS feed out there with more panache with a Feedburner account (easily logged into with your iGoogle account). This plugin replaces the default feed and uses the Feedburner feed instead. Once you’ve set up your Feedburner account you can customize it with a ton of options that will help spread your blog around and gather interest to your site.

  5. Google Analytics for WordPress:

    This plugin automagically puts your Google Analytics code on each page/post as appropriate. It’s a great way to get some basic stats and easily integrates with your website. There are plenty of free analytics packages out there, but this one is really simple to get started with and monitor.

  6. Google XML Sitemaps:

    When you update your blog this plugin makes all the necessary updates so Google can parse your site more easily. Highly recommended, especially in conjunction with the “All in One SEO Pack” above!

  7. Permalinks Moved Permanently:

    If you ever rethink how you’ve categorized posts or decide to update posts on the back-end, there’s a good chance that you’ll eventually run into a problem with broken permalinks. This plugin is a great go-between that helps you out while you’re finding the broken links because it tries to find the update permalink and send them to the right page, all seamlessly.

  8. PS Disable Auto Formatting:

    The PS Disable Auto Formatting plugin lets you get rid of the automated formatting that exists in WordPress posts. Take control of your blog’s posts and sculpt the markup as you wish. There are a few minor things to update and/or remember when using this one, but if you want to control your HTML in a post it’s a great plugin to have.

  9. WordPress Database Backup:

    Don’t get caught with your pants down! If your WordPress ever gets corrupted or if you get hacked, make sure you have a backup with this plugin. It can be configured to automatically backup your content so you can repair if/when necessary.

  10. WordPress Gravatars:

    So you’ve read my Gravatar post and want to hook up your blog readers, have you? Just install the WordPress Gravatars plugin and you’ll be on your way. This plugin makes it really easy to have your commenters feel like a part of the blog.

One more thing to note: To make sure your WordPress blog runs as efficiently as possible, be careful how many plugins you install and use. Too many plugins can actually slow things down on your website.

Do You Want a Custom Blog Comment Avatar?

Do You Want a Custom Blog Comment Avatar?

If you’re looking to spice up your blog comments a bit, sign up for a (free) Gravatar account. Many websites have an option to display the avatar of your choosing wherever you comment on a blog (based on the email address you use to comment), and it’s a great way to add a little something extra when you post. Gravatar plugins are available for most (if not all) major blog software platforms, so there’s a heck of a good chance you’ll be seeing your new Gravatar the first time you make a new comment.

Setting up a new Gravatar account is easy. Just follow these steps:

  1. Go to http://en.gravatar.com/site/signup/ and enter your email address.

  2. Check your email for the activation email sent by Gravatar.com. Click on the link in the email. (Be careful of line-wrapping if you choose to copy+paste the URL instead!)

  3. Enter the username you want to use, as well as a password. When you choose an available username and click “Signup” your account should be created.

  4. Now you just have to select a picture to associate with the email you signed up with. Follow the directions listed on Gravatar.com.

That’s it. Everything else is hands-off for you. And the next time you are on a Gravatar-enabled website and leave a comment with your selected email address, your Gravatar will show up in the comments. Enjoy!

Update: Diana Adams also has great post on Gravatars at Bit Rebels.

Image copyright http://Gravatar.com/