Hosting Rails app and Wordpress on same domain(as folder instead of subdomain)


Hey guys, Yesterday I did an interesting server configuration. Actually we had a rails app hosted on server which is using passenger(a.k.a mod_rails). This application can be access by going to http://domain.com . Also we had a wordpress running which could be access by going to http://blog.domain.com.

But, for SEO sake I had to change configuration so that wordpress can be access by http://domain.com/blog instead of http://blog.domain.com/

The problem was if I configure wordpress for http://domain.com/blog and go to this url, the request was handled by rails app because of domain.com virtualhost.

So what I did? I changed apache virtualhost configuration for http://blog.domain.com and http://domain.com as:

Also I created a symbolic link to wordpress installation directory under rails public folder(ln -s /var/www/html/wordpress /var/www/html/railsapp/public/blog).

Now remember to change your wordpress address and blog address options to http://domain.com/blog under settings tab of wp-admin section.(Thanks Amit for pointing this out)

I restarted apache and it worked fine. Wordpress was running at http://domain.com/blog and rails app was as http://domain.com/.

Update: If you want to change your wordpress permalink structure in account of SEO please change “AllowOverride None” to “AllowOverride All” as shown in image below.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Configuring TinyMCE SpellChecker with rails application
Leopard sucks while installing/updating gems
If my code or post helps you then please recommend me at workingwithrails.com by clicking on button below:
Recommend Me

Reader Comments

Thanks for the post brother.
~Amit

Thank you for this post. I am having one issue though.

when I go to http://www.domain.com/blog I get redirected straight the the http://www.domain.com homepage

However, http://www.domain.com/blog/wp-admin works perfectly fine.

Any ideas what could be wrong with the setup?

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.