Redirecting Webfaction Subdomain to AWS

I just started playing around with AWS. I have a domain name that is served by Webfaction. I wanted to create a subdomain and point it at my AWS EC2 instance. Seems like it should be pretty easy. But the time it takes for domain name propagation makes makes it hard to debug.

The first thing to note is the command:

host domain_name.com

lets you know if propagation has been done.

CNAME

The first approach I tried was to set the CNAME for the subdomain using the Webfaction control panel. The was super easy, but it did not work. It appears AWS will not allow that. For more info, see here.

.htaccess

The other approach is to create a static site on Webfaction and use .htaccess to redirect. Something like this. One advantage of this approach is once the domain name has propogated, you do not need to wait for it to re-propagate if you change .htaccess.

If you get a 500 error, you can inspect the Webfaction logs to find out what went wrong. The log you want is ~/logs/apache/error_my_app_php.log.

Here is the htaccess file that worked for me:

Redirect permanent / http://ec2-xx-xx-x-xxx.compute-1.amazonaws.com
order deny,allow

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s