(Note: This post somewhat of a story, but also has some useful code design info.)
Domain mapping is a handy and common way to set up a custom URL for your hosted blog, such as one on TypePad.com, WordPress.com or Blogger.com.
This allows you to use MyExample.com to reference your blog, instead of something like myexample.typepad.com.
But what if you want to change the name you originally set-up to something else? In the case of TypePad (and likely other platforms), this can cause serious issues.
All of your posts and images use the original name, such as in search engine listings, on trackbacks and more. So if you change the name, all of your old links will break. You might loose a bunch of RSS feeds that used the old links. And also, all of the images in your posts will be missing!
I ran into this issue for a client last week. A popular blog, with an average of 1,500 unique visitor per day, and over 2,100 posts, was essentially broken. Not acceptable.
Because of TypePad’s inept support I was forced to find a solution, which can likely be adapted for use on other hosted blogging systems as well. The answer lies in some simple .htaccess code. Read on to find out more.
First, a rant against TypePad. TypePad doesn’t have live support. At all. Six Apart, the parent company, doesn’t even maintain their own support forums. With no other recourse to solve the issue, I opened an online help ticket.
We were told that the issue was a tough one, and would be looked at by technical support. After a week of back and forth, asking if there was any progress, TypePad finally responded that there was nothing at all they could do.
Sorry, they said, but even though you have been customers for over 5 years, tough luck.
I tried asking @sixapart on Twitter for help. No response whatsoever.
Ouch! I called GoDaddy.com, where the domain name is registered, to see if their live support team had any ideas. While they were helpful and friendly as ever, they didn’t see how to fix the problem. But that’s when I myself realized how to do it.
An .htaccess file is a text-only file that web servers read first, before any other pages on a site. Turns out it’s a common way to fix issues that might occur when you switch your domain name!
In TypePad, all blog posts live in a sub-folder of your main domain, like “my_example”. In this case, the original links, now broken, were www.myexample.com/my_example/my-post.html, and the new links, after changing domain mapping, were blog.myexample.com/my_example/my-post.html.
Very similar links, and a simple replacement: just find anything with the /my_example/ in its address and send it to blog. instead of www.
To create an .htaccess file, all you need is a simple text editor. Open the file, type in your code, and save with the extension .htaccess. You might have to give the file a name, like a.htaccess, but just make sure to remove the preceeding “a” before uploading to your webserver. [More on .htaccess files here and here.]
For this specific redirect, the code in the .htaccess file is the following:
Redirect 301 /my_example/ http://blog.myexample.com/my_example/
.
It worked to fix all the old, cached, search-engine-indexed, mentioned-by-others posts’ links. However, images are a separate line of code.
In TypePad, all images you upload to their severs are stored not in your /my_example/ folder, but in a directory called /.a/
Why? Who knows. But all that means is we need another line in the .htacess file:
Redirect 301 /.a/ http://blog.myexample.com/.a/
.
Upload the file to the root level of your site, and done. Phew. SixApart, please take note, and save other customers some anguish.
If I want to retain my domain but use a .htaccess file to 301 my /directory_path/, how can I retain images?
1) I keep active the install @ /foo/
2) I create a new install @ /bar/
3) I upload a proper 301 to the “foo” blog directing all requests to “bar”
Must I keep foo and bar both active on my Typepad account to retain images? Image paths won’t need to change for me, because I’m not changing domains. I don’t want broken images in my posts. I have 3500 blog posts on “foo”.
Thank you! I didn’t think you could add .htaccess files to the root directory on Typepad (because I read that in a more recent blog post comment from a Typepad employee.) Yippee!
Can you please tell me how you uploaded to Typepad’s root directory for your blog? I assume it’s in the file library, but what folder do you navigate & upload to?
Hi there – I’m so sorry that you had this experience! Usually, a help ticket or Twitter is a good way to reach us (I just saw your Tweet about this blog post) but there must have been a crossed wire here someplace.
Thank you for the suggestion on the 301 redirect. If ever you have questions or problems in the future, please feel free to reach out to me directly and I’ll help.