Simple .htaccess Tricks for On-Site Optimization

This post goes out to all the site owners/developers out there who are running a site using the Apache server. You want to optimize your site for search results, but the whole task seems rather daunting. We’ll be honest, it can be. But before doing keyword research, building landing pages, and perfecting your internal linking structure, there are some basic on-site modifications you can make first. This list represents some of the most common on-site mistakes SEOs encounter. Luckily, they are also some of the easiest to repair. All of these changes can be implemented by simply adding a few basic lines of code to the site’s .htaccess file.

How to Edit the .htaccess

Accessing the .htaccess:

Using an FTP client, you can log in to your domain and edit the .htaccess file from there. (My preferred FTP client is Filezilla.) Your FTP login should be available from whatever host you are using (e.g., GoDaddy, Bluehost). For those of you who have access to a cpanel (control panel), the .htaccess file will be available from your File Manager. If unable to find it immediately, make sure you display hidden files, as sometimes it is hidden by default. In most cases, you should already have an .htaccess file available to select from the existing files; otherwise you will need to create one.

Creating an .htaccess file:

If there is no sign of a .htaccess file, you can create one. (You’ll want to double or triple check this and cross-source with some other resources before reaching this conclusion, to make sure you are not creating a duplicate.) Open a text editor program (Notepad for PCs or TextEdit for Macs). Make sure to name the file exactly “.htaccess,” not “htaccess.txt” or any other file extension. Only use lowercase letters and make sure a dot precedes the “htaccess.”

Simple Tricks for SEO

Once you have created or opened the .htaccess file, you are ready to make some edits. Each of these simple lines of code make a BIG difference as far as overall site health and performance. If you are unsure whether or not your site includes these directives, it is worth checking. We generally recommend that every site have these included in the .htaccess file.

1. Disallow index files.

Every site is built in terms of directories, which are essentially folders. Each of these directories contains files that represent individual web pages or pieces of media. However, in many instances, a particular file within the directory is not called out in the URL. So for example: Thus, each directory should include an index page (e.g., index.html). These index pages essentially tell the server to display this page by default if a specific file is not requested. When a server is told to look up a directory that does not contain an index file, all of the files in that folder will be displayed instead (see image below). In other words, if the server is not directed on which file to display by default, it displays a list of all of them.

Website directory that does not contain an index file

Why should you care? For one, there are potential security issues that come along with this. It’s not enough to be a major security problem on its own, but if someone is already looking to breach your security, it’s effectively giving them a tall glass of lemonade. aHere you go Mr. Hacker, thanks for all of your hard work. Enjoy!a Another, possibly more important, issue is bad user experience. This page is ugly to say the least. It’s definitely not helpful to the user. If you’ve ever stumbled upon one of these pages yourself, I can imagine you didn’t stay for long trying to figure it out. How To: Disallowing index files prevents servers from producing directory listings for anyone to see. Insert the following code into the root folder of the .htaccess file:

Options -Indexes

Now, if someone enters a directory name that is missing an index file, they will be shown a 403 Forbidden Error. As discussed later in this post, this page can be easily customized in order to give the user instructions on what to do next.

2. Redirect www to non-www (or vice versa).

Google treats and as completely different pages from one another. Without redirecting one page to the other, most sites have identical pages located on both versions. Why Should You Care? If there are links to both the www and non-www versions of pages within a domain, this can lead to what is known in the SEO world as “duplicate content.” It’s bad because it splits up the authority of these pages among the different versions, which have acquired links. It can also, in rare instances, lead to penalties. Therefore, it is important to set a preferred version for every website and redirect all URLs within the domain to that version. Whether you prefer the dub or non-dub is totally up to you, search engines do not have a preference. How To: Using 301 Permanent Redirects, all of the authority of the non-preferred pages will be moved to the canonical (preferred) version. To redirect to the www version of the site, insert the following code into the .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

To redirect to the non-www version of the site, insert this code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

(Remember to insert your domain name where it says “example.”)

3. Remove Directory Indexes from the URLs

We already discussed how directory indexes (i.e. “index.html”) are important. We want these to exist, definitely. But we donat necessarily want them to appear at the end of the URL. Why Should You Care? While these pages are helpful to the server, the directory index does not help the user. In fact, it is just one more parameter for them to type into their browser, or to copy and paste, or what have you. Also, this can be another big contributor to duplicate content, as discussed earlier in this post. If the same page exists at “” and “”, this is no good for SEO. One way to clean up a site’s URL structure is to remove extra directory indexes from the URL. How To: Add a rewrite rule that instructs the server to redirect all pages with that ending parameter to a URL without it. Insert the following code to the .htaccess file:

RewriteCond %{THE_REQUEST} /index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
4. Create Custom Error Pages

Even the healthiest sites have errors every now and then. These most commonly include 404 Not Found errors, for pages that have been deleted or moved. This also includes things such as 500 Server Errors, 403 Forbidden Errors, etc. The causes for these vary, and there are different ways to fix them based on SEO best practices depending on the cause. But that’s a topic for another day. Create custom error pages The first, and easiest step, is to create custom error pages. This ensures that if a visitor does encounter one of these errors, they will be less likely to abandon ship. Why Should You Care? From a user experience perspective, errors can be detrimental. If you’ve ever seen an ugly error page like the one above, I’ll take a wild guess that you didn’t stay on that site very long. Errors are still a big problem and should be a priority to fix. However, the process can be a long one. In the mean time, you have the opportunity to salvage some of the potentially lost revenue and bad user experience by creating a custom page. Custom pages can include an apology for any inconvenience and direct instructions on what the user should do next. How To: In order to do this, you just need to reference custom pages in your .htaccess file. Add the following lines to your .htaccess, one for each custom error page you’ve created:

Error Document NUM /folder/name.extension

Some examples:

ErrorDocument 404 /errors/not-found.html
ErrorDocument 500 /errors/server.html

Back Up and Test!

Please remember to:

1. Back up your .htaccess file. Before you make any of these changes, save a copy of your .htaccess file! If something does go wrong for whatever reason, you will be able to re-upload the original .htaccess, preventing you from going in to panic mode. 2. Test your site. After making any change to the .htaccess file, make sure to test out the site to make sure it’s working. Checking after each update will help determine where/if a problem arises.


As SEOs, we hate to see an awesome site with simple errors holding it back. Many site owners donat realize that these issues exist and how easily they can be repaired. We encourage you, as a site owner, to ensure that these errors are avoided/corrected as much as possible. It doesn’t take a rocket scientist, or even a development background, to fix some core issues that could be preventing a site from performing in search.

Connecting with Consumers through Search

Today Derek spoke at IABC’s seminar, The Communicators’ Toolkit, about the ability for brands to use Search as a means of connecting with consumers. The purpose of using keywords on a website isn’t to bait people online; it’s to match your brand’s services and products to the needs of a searcher.

If your website is receiving primarily branded traffic, you are missing out on the opportunity to connect with the larger audience that is unaware of your brand – yet has needs that your services or goods can fulfill.

Derek talked about the importance of understanding a buyer persona before diving into keyword research, then making sure a website is able to rank for terms that attract audiences in all stages of what we call the “sales funnel.” To break it down simply, most people start searching with a vague problem in mind. As they perform additional research, they refine their queries to be more specific and often inclusive of a brand name.

Check out the presentation below:

Digital Passive Aggression: A (Silly) Guide to Negative SEO

Your gym charged double for last month’s membership. The site from which you bought textbooks never shipped them, nor refunded you. Whatever the reason, you’re mad. But as you know, it’s 2013. And if there’s one way we love to lash out, it’s passively, dammit. Iam here today to present a list of ways you can do so without having to actually confront anyone. Disclaimer: I don’t condone sabotaging a brand’s reputation or success online. These are merely hypothetical, highly passive aggressive scenarios that you could feasibly carry out if you were burning with an undying passion and needed to do something about it before you snap (by the way, try yoga first). Anyway, this is simply a lighthearted post about reverse-SEO tactics. Why so serious?

Fair, but firm:

Forget the customer service line. Passive aggression is about attempting to teach a lesson without actually having to talk to anyone about it. Here’s where you can start:

Giving bad reviews

The digital manifestation of feedback is the best and worst thing to happen to local institutions. I know I’m not the only one who religiously refers to Yelp or Google+ Local when scoping out a new Thai joint or choosing a daycare center for my kid (okay, my dog). On the flip side, as a consumer, it’s empowering to be able to amplify my feedback for others to digest. Personally, I often hold my breath unless I’m desperate to shout from the mountaintops how much I freaking love a local brand’s service or product. Why take the time to write a review? Google is a business, too. When someone is searching for “eye doctor maplewood,” Google wants to deliver a list of the best optometrists it can find in order to retain that person’s trust. A huge indication to Google of the quality of a business is the number of positive reviews. Likewise, a boatload of single-star ratings attached to a brand is going to hurt its visibility in Local Search. So go ahead: tell that brand what you think, especially if your feedback will allow the company to grow and learn from your experience. Or heck, do it just to spite them.

Make the site your default startup page on your browser

Depending upon the extent of your aggression (and especially the extent of your passiveness), you might be interested in spanning your efforts over a long period of time. If that’s the case, bless you, and listen closely. Go to your browser’s preference settings and change the start-up page to be the dumb website of the brand you hate. At the very least, add it to your list of “favorites” so you can easily access it. Now every day, make sure to visit the homepage, but leave before clicking through to secondary pages. Why take the time to visit the site? You may be just one person, but to that site, you can be a passive aggressive pain in the digital arse. By refusing to explore additional pages, you’ll help increase that site’s bounce rate (depending, of course, on the amount of traffic it receives). Will this matter to them? Probably not, actually. But you can laugh quietly, maniacally, to yourself at night, and imagine the Bounce Rate swelling in Analytics. You cunning sonofagun.

Evil, but I get it:

If you’re wanting it to hurt a little more, you fit into this category.

Clicking PPC ads

Maybe it makes me evil. Maybe it makes me genius. Regardless, I never hesitate to alleviate my rage for a certain student loan lender after flushing a solid chunk of my budget down the pipes every month. How do I do it? Easy. I search a broad term (in my case, it’s usually “student loans”) and click away on the highest-position ad belonging to the brand I want to ruin. I immediately return to the search page and repeat the process.


Why take the time to click ads? The broader the term, the most competitive and expensive the cost. Brands don’t have to pay for the ad to show up; they only have to fork over money if someone clicks through. And that’s where you come in, assuming the company you want destroyed is running PPC campaigns. Search. Click. Smile.


Linking from your lame personal site

If you have your own website, you’re in luck a especially if its Domain Authority is hovering at a 14 like mine is. So I’ve never actually used my blog for bad, but if I were desperate enough to evoke some pain, I might try leveraging my crappy website for evil. Why take the time to link from my site? Links from shotty domains can often weaken the backlink profile of a brand (especially if its portfolio of inbound links is already thin). You could also trash talk the brand in your posts and hope that Google starts associating the company with certain negative keywords, which would then populate in Google Instant results. This tactic isn’t very practical or measurable a and honestly, it will probably make you look like a Bitter Betty. But that’s what passive aggression is all about, I guess.

Psychotic, also, you should see someone:

I’m not going into extreme detail about these because I have zero experience performing any of these extracurricular activities. I solemnly swear. But it’s interesting to think that there are people out there who actually do “negative SEO.” These efforts are not okay. Probably not even legal. And the people who do them are clinically insane.

Scraping content

Duplicate content can harm a website’s ability to rank and thrive because it harms the user experience. If your site is guilty of possessing multiple pages (different URLs) that have identical or nearly-identical content, you’re probably pissing off the search bots and your customers. (There are exceptions.) So what Negative SEOs do is scrape content from sites they want to bring down and replicate that information on random sites. This positions them as guilty of pursuing shady duplicate content strategies. It’s awful.

Hacking FTP and editing robots.txt

I especially don’t know how to do this, but I guess all you need to do is hack a site’s FTP and add a few key URLs into the robots.txt, a file that specifies to bots which pages are OFF LIMITS. So yes, assuming you decided to slip some important pages into the robots.txt file inconspicuously, you could cause serious damage and possibly bump pages from Google’s index.

Buy some links, ruin some lives

Last year, Googleas Penguin update cracked down on websites that engaged in manipulative tactics to rank higher. One huge red flag was (and still is) a shady backlink profile. For instance, a website that attracts thousands of really low quality links from sites that aren’t even related to the brand is likely purchasing them in order to appear as more valuable than it is. As a fellow agency showed in its Negative SEO case study, this tactic works against websites today. And at bargain price.


Before you go on a digital killing spree, remember to take this post not at all seriously. Instead, I hope you realize how many components are taken into consideration for Google to determine the quality of a site. You have the ability to influence the rise or demise of a website’s visibility in search engines. Isn’t it empowering? I know this isn’t an exclusive list; what did I miss here? Leave a comment below!