Using htaccess to create friendly redirect URLs

I just got an email from an innkeeper with a question I have received several times before.

In an effort to send emails to guests to invite them to write reviews, the long and ugly link from TripAdvisor needs to be included in the email. Occasionally the links are “broken” by the email client or even in the wrapping of the text on a page. Earlier this weekend, I got an email from another client asking about creating a nicer URL for their new facebook page. There is a simple answer to both of these issues.

Here is a quick and easy fix for this and other ugly URL issues.

Open up your htaccess file (or have your webmaster edit the file) and add a 301 redirect for the URL you would like to share.

The code is simple

redirect 301 /urlyouwant http://www.blahblah.com/reallyuglyurl

which would create a new “page” on your website at www.yoursite.com/urlyouwant

For example, instead of sharing this link:

http://www.tripadvisor.com/Hotel_Review-g57192-d82517-Reviews-Forty_Putney_Road_Bed_and_Breakfast-Brattleboro_Vermont.html

you would be able to share this:

http://www.fortyputneyroad.com/tripadvisor

using this code:

redirect 301 /tripadvisor http://www.tripadvisor.com/Hotel_Review-g57192-d82517-Reviews-Forty_Putney_Road_Bed_and_Breakfast-Brattleboro_Vermont.html

You can use this same redirect code to point any url to any other url. Try it http://www.fortyputneyroad.com/tripadvisor here.

Tags: , ,

2 Comments

Leave a comment
  1. Sarah 03. Feb, 2010 at 1:03 pm #

    Tim, what is the advantage to this versus just making the words “TripAdvisor” a link using your email program?

  2. Tim 16. Jun, 2010 at 11:31 am #

    Hi Sarah, Don’t know how I missed your comment, sorry about that! The advantage is really just ease of inclusion. Its a lot easier to type myinn.com/tripadvisor than it is to use the full link. Also in many cases, the long URL will wrap, and not work properly. Cheers! Tim

Leave a Reply