Marko Anastasov wrote this on June 26, 2009

Redirecting from the old blog

Initially we started with a Wordpress site on a subdomain for our blogging. Now that we’ve moved to our fork of Enki, when shutting down the old one it would be wise to set up URL redirection to here. That’s of course what mod_rewrite is for.

The trick is not to attempt to put any such global rewrite rule in your Rails application’s .htaccess file (ah, remember the days when Passenger didn’t play well with mod_rewrite?), but in the vhost configuration file (the one in /etc/apache2/sites-available/).

Fortunately the URLs look pretty much the same, and all it takes is a subdomain to directory kind of redirection, so it doesn’t involve a complex rule. Here’s what it looks like:

<VirtualHost *>
  ServerName www.renderedtext.com
  ServerAlias renderedtext renderedtext.com
  DocumentRoot /var/enki/public

  RewriteEngine On

  RewriteCond %{HTTP_HOST} ^blog\.renderedtext\.com [NC]
  RewriteRule ^(.*)$ http://renderedtext.com/blog$1 [R=301,L]
</VirtualHost>
comments powered by Disqus

About Marko Anastasov

Rendered Text co-founder. Started with code, currently more focused on people and words. Foosball striker and entry-level cyclist.

Suggested Reads

Rails Testing Handbook

A new ebook on building test-driven Rails apps with RSpec and Cucumber.

At Rendered Text, we have a long history with Ruby on Rails. Checking the blog archive reminds me that we published first posts about working with Rails way back in 2009.

———

Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.