Be an .htaccess hero in 3 simple steps
Your palms cover your sweaty face, your heart rate rises, and your extremities flail as someone squawks distantly, “We’re going to need to edit the dot H-T-Access file.”
Naturally, your first instinct is blame WordPress, the IT guy, GoDaddy, or really anything so that you don’t have to do it.
But hold on – while everyone else is running from the building, this could be your moment to shine.
You don’t need to be an expert in .htaccess to look like you can walk on water. A few simple tricks could get you a pat on the back from your boss, a warm hug from a client or even an awkwardly slow kiss on the center of your forehead.
Hyper text access 101
Before diving into what the .htaccess file can do, it’s important to understand what it is.
So here goes: it is a file extension placed on the root level of a site to make configuration changes*. And it’s a great place to perform basic changes to your site.
Even if you’re familiar with .htaccess, you still may not know who’s responsible for it at your job.
But SEOs who step up to the plate could be rewarded with search optimization wins in the form of canonicalization, 301 redirects and 404 error pages. Let’s take a look at each.
Not that stupid word. Everybody is tired of being confused about canonicalization. Nobody can pronounce it, nobody can explain it, and nobody knows if it is even a real word. Well, today’s the day we simultaneously put our feet down and end the confusion.
“For every URL, variations exist.”
There it is, laid out into something you could tattoo on your lower back for less than 100 bucks.
If you can remember that one sentence, you’re on the right path to fix a lot of the low-hanging fruit that may exist on your website.
Just whip out that mirror you carry in your back pocket, and away you go fixin’ issues that could potentially cause duplication issues on SERPs and lead to excessive crawl time for the spiders. All while remaining cool for the ladies.
Pro tips for canonicalization:
- www vs. non-www URLs: This is the big one. It doesn’t matter which one you choose, but pick one and make sure your site 301s (not 302s) to the correct variation.
- Customize how your URLs display in Google search: Once you complete the point above, log into your Webmaster Tools account and on the left sidebar select “Configure > Settings > Preferred Domain.”
- Variations of the homepage: Make sure variations of your homepage are redirected back home (i.e., /index.html, /default.asp, /default.php)
- Trailing slash: Make sure all URLs either have or do not have a trailing slash at the end of each URL. Pick one and remain consistent when building links.
Three hundred and ones, three-oh-ones, trescientos uno; no matter how you say it, this is fancy talk for moving existing pages on your site to a new home.
Perhaps you recently retired a product, and instead of completely wiping it off the web you’d rather send those potential customers to a similar page. BOOM! Look at you keepin’ link cred and generating leads likes a badass mo’.
Pro tips for 301 redirects:
- Address dead pages: When a page is retired, be sure to update the old link to the new URL. This reduces the dependence on 301s in the future.
- Alphabetical: Please alphabetize. Nobody likes a slob.
- Avoid pointing 301s to other 301s: See below.
- Be cautious of 301 loops: See above.
- Helpful Tools: Raven Tools Site Auditor (Web Based), Screaming Frog (Mac/Windows), Link Examiner (Windows)
- Longest first: If your site is multiple levels deep, redirect the deepest URLs first
- First: /animals/birds/ravens
- Second: /animals/birds
- Third: /animals
- Simplify URLs: Make URLs as clear as possible. If you have events that run annually, try something like /sales-event instead of /sales-event-2012. This will reduce the need for 301s in the future, and will hold on to links built. Plus it’s easier to remember.
404 error page
Everybody loves a whimsical error page (http://markoleszczak.com/poop), but 404s also serve as a way to inform users and search engines that a page is not located at that address.
In fact, not only do 404 pages serve a purpose, they’re an excellent time to showcase your attention to detail and convert visitors despite their unfortunate landing.
Pro tips for 404s:
- Convert visitors: Maybe you didn’t intend for someone to land on the page – but make the most out of it. Add links to best selling products. Provide newsletter sign-up form. Share social links.
- Correct status code: Make sure your site is firing a 404 error, and not 301-ing to your error page instead. Screaming Frog can test this.
- Make it fun: Everybody messes up. Use this moment to show that your company has a sense of humor and can handle not being perfect 100% of the time.
So there you have it: three big reasons to get to know .htaccess. What hero moves do you have with it? Let me know in the comments.
Top image courtesy YouTube