scriptygoddess

06 Oct, 2003

Using .htaccess to Domain Map Typepad

Posted by: Jennifer In: Lessons learned

Typepad just added domain mapping. This allows you to point your domain at your blogs.com subdomain via DNS. I wanted this because I didn't want my blog at blinne.blogs.com but rather at www.blinne.org. But, I also wanted other content at www.blinne.org. This meant I couldn't simply repoint www.blinne.org to blinne.blogs.com via DNS. My solution to this problem is outlined below.

Most of the time, the configuration of the Apache web server is done in a centralized fashion. In addition to this, Apache provides for decentralized control with a .htaccess file placed in the same directory as the rest of your files. This gives the end user some control over how the web site will function. Apache is also a modular HTTP server. This allows for extensions to the server. Examples of such modules include mod_perl where Apache runs perl natively and mod_rewrite which we will be discussing today. Whether you can use this or not depends on two things, the web hosting company allows you to use .htaccess and also has mod_rewrite installed. Check with your web hosting company for these details.

The rewrite engine in Apache provides a number of ways to redirect traffic. Most people use the the normal redirect. When that happens, the URL in the location bar of your browser changes. There is also a proxy mode that doesn't change the location bar. When you use proxy mode, Apache inserts itself as a proxy between the user and the web site. It fetches the web page on the remote site and presents it as if it is local.

Here's what I did for my web site hosted by frii.com and my blog hosted by typepad.com. My .htaccess file looks like this:

RewriteEngine on
RewriteRule ^blog/(.*)$ http://blinne.blogs.com/blog/$1 [P]
RewriteRule ^blog$ http://blinne.blogs.com/blog/ [P]
RewriteRule ^/$ http://blinne.blogs.com/ [P]
RewriteRule ^$ http://blinne.blogs.com/ [P]
RewriteRule ^about.html$ http://blinne.blogs.com/about.html [P]
RewriteRule ^foaf.rdf$ http://blinne.blogs.com/foaf.rdf [P]

The structure of what I was mirroring looks like this:

http://blinne.blogs.com/about.html
http://blinne.blogs.com/index.foaf
http://blinne.blogs.com/blog/{the rest of the blog}

The first line turns the rewrite engine on.

Line 2 maps the entire subcontent under the directory blog. (.*) of the regular expression corresponds to $1 on the right hand side. From here on out, each line consists of a regular expression that matches a URI and a URL to map it to. The [P] at the end of each line tells Apache to proxy.

Line 3 handles the case http://www.blinne.org/blog without the trailing slash.

Line 4 handles the case http://www.blinne.org/

Line 5 handles the case http://www.blinne.org

Line 6 handles the case http://www.blinne.org/about.html

Line 7 handles the case http://www.blinne.org/index.foaf

I uploaded the .htaccess file into the top-level directory for my web site. Then,I went to the control panel for typepad and then to the domain map, lied about DNS working, mapped www.blinne.org to blinne.blogs.com, and finally activated it.

This is what it looked like on Typepad

And I am now running www.blinne.org on Typepad without remapping my DNS!
One last little note, you will get "charged" for the bandwidth both at the local and remote site. If that is a concern for you, DNS mapping is definitely the way to go.

9 Responses to "Using .htaccess to Domain Map Typepad"

1 | Snowman

October 7th, 2003 at 8:53 am

Avatar

I think you need a carriage after the first two words in your code.

Thanks for the great article, I'm gonna test it now

2 | Jennifer

October 7th, 2003 at 9:08 am

Avatar

Fixed. That was my faut. :)

3 | Snowman

October 7th, 2003 at 4:29 pm

Avatar

I'm having great problems implementing this on my server. I'm told that mod_rewrite is installed, but when i put the first line into the .htaccess it gives me a "you do not have permission" message when accessing via HTTP.

Any suggestions?

4 | Rich

October 7th, 2003 at 8:11 pm

Avatar

Apache is probably accessing your files as nobody. Make sure .htaccess is universally readable. Under UNIX this is:

chmod 644 .htaccess

If that still doesn't work, most likely your ISP is not allowing you to use mod_rewrite.

5 | Rich Blinne

October 7th, 2003 at 8:15 pm

Avatar

I verified my previous comment. If you don't have your permissions right on .htaccess, Apache won't allow you any access at all.

6 | Rich Blinne

October 8th, 2003 at 11:36 am

Avatar

One downside that I am noting is that Google is not properly crawling my site. So, I am trying the variant of having [R=301,L] instead of [P] in my .htaccess. I also took out the domain mapping in Typepad.

A 301 redirect tells Google that my site has permanently moved. Hopefully, my Google page rank goes with me. I'll let you all know if this works. The other upside is that my local ISP won't charge me for bandwidth.

7 | Rich Blinne

October 9th, 2003 at 12:46 pm

Avatar

Google found my stuff, so I am back to my old way.

8 | Anton Zuiker

November 9th, 2003 at 11:28 pm

Avatar

Thanks for this info. Seems just what I need to be able to map zuiker.com to my TP blog (mistersugar.typepad.com/staging) – I mapped it TP's way, through Dotster, and found out that all of my other content (family tree, archived photos, etc.) was suddenly unavailable.

My only question is this: in the code above, line 2, what does the ^blog/(.*)$ refer to a directory blog on your server or on your TP space? If it's your server, how do I know what my corresponding directory should be?

Thanks again.

9 | The Blinne Blog

October 8th, 2003 at 4:08 pm

Avatar

Scriptygoddess Guest Post: Using .htaccess to Domain Map Typepad
Check out my guest post on scriptygoddess. Here's an excerpt:Typepad just added domain mapping. This allows you to point your domain at your blogs.com subdomain via DNS. I wanted this because I didn't want my blog at blinne.blogs.com but rather

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements