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

Published on Author Akhil Bansal31 Comments

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 . Also we had a wordpress running which could be access by going to

But, for SEO sake I had to change configuration so that wordpress can be access by instead of

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

So what I did? I changed apache virtualhost configuration for and as:

<virtualHost *>

    DocumentRoot /var/www/html/wordpress/
    <directory "/var/www/html/wordpress/">
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all

<virtualHost *>
    DocumentRoot /var/www/html/domain/current/public
    <directory "/var/www/html/domain/current">
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all

  RailsAllowModRewrite  on
  RewriteRule ^/blog/?(.*)$$1 [P,NC,L]


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 under settings tab of wp-admin section.(Thanks Amit for pointing this out)

I restarted apache and it worked fine. WordPress was running at and rails app was as

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.

31 Responses to Hosting Rails app and WordPress on same domain(as folder instead of subdomain)

  1. Nice one, will give it a try.

    Was looking for using opensource rails forums like Beast but I think WP would be a good alternative (esp. with forum plugins in wordpress)

  2. I am on Apache/2.2.14 (Ubuntu) and Passenger 2.2.15.

    I added the stuff but I still get a 404. I am however now clearly skirting passenger, as before the 404 page was the one served up by Rails and now it is the apache default.

    Any more ideas?

  3. Vhost config for the blog:

    <VirtualHost *:80>
      DocumentRoot public_html/

    Vhost config for the app:

    <VirtualHost *:80>
      DocumentRoot public_html/testapp/public
      <Location /blog>
        PassengerEnabled off # turn off Passenger for /blog subdirectory
      RewriteEngine On
      RewriteRule ^/blog/?(.*)$ /public_html/$1 [NC,QSA,L]

    I think the paths are correct. Thanks for taking a look!

  4. Ah yeah! Sweet.

    I changed my testapp config to:

    RewriteRule ^/blog/?(.*)$ /etc/apache2/public_html/$1 [NC,QSA,L]

    But now I am still hitting the rails app when I go to a sub-page on the blog. Any post I try to look at takes me to the index of the Rails app.

    Thanks again for any wisdom you can drop on this problem.

  5. We stumbled over here by a different web address and thought I should check things out.
    I like what I see so now i’m following you. Look forward to exploring your web page for a second time.

  6. Last week I lived them all and learned some important lessons about being a better networker.

    Another key stage in document or record management concerns the disposal
    of files that are no longer required by a company.
    Almost everyone knows his most popular work “David” which he created for the cathedral of Florence but
    the original work is now preserved in The Gallery of the Academia di Belle Arte.

  7. Thanks for one’s marvelous posting! I quite enjoyed reading it, you will be a
    great author.I will be sure to bookmark your blog and will often come back later on.
    I want to encourage you to continue your great writing, have a nice

  8. I rarely leave responses, however I browsed a lot of comments on this page Hosting Rails app and WordPress on
    same domain(as folder instead of subdomain) | WebOnRails.
    I do have some questions for you if you do not mind.
    Is it simply me or do a few of the responses
    appear as if they are written by brain dead folks? 😛
    And, if you are writing on other online social
    sites, I would like to keep up with anything new you have to post.
    Could you list of all of all your shared pages like
    your linkedin profile, Facebook page or twitter feed?

  9. Could not agree far more. Couponers could find on their
    own buying things they don’t want or want! In addition within the long run couponing (in my experience) tends
    to make quite tiny difference to kinds overall budget.
    I understand this will likely upset several individuals but it is

  10. The major attraction on these islands is that they blend both nightlife as well as a relaxed beach life and this is also enhanced by the natural beauty as well as the unspoiled beaches
    that are found on these islands. 700 Einwohnern ist diese Gemeinde die kleinste der Kanarischen Inseln.
    These differences only mean that there are lots to be explored and discovered within the Island.

  11. This activity is equally important for boys as some of them would
    love to take care of dolls and bears. Offer positive
    praise to your child as often as you can. Ideal club fitting requires several straightforward measurements and a quick assessment
    of your child’s skill.

  12. Fantastic beat ! I would like to apprentice while you amend your site, how
    could i subscribe for a blig website? The
    account helped me a acceptabhle deal. I had been a little bit acquainted
    of this your broadcast provided bright clear idea

  13. Buenas he alucinado con tu post no te conocía
    a partir de ahora. Mi más sincera felicitación tienes un sitio
    super interesante Gracias por compartir con todos.

  14. For aged people, exercise is the best way to lose weight but for a child it is very essential that they should be very active
    and should participate in different activities that will burn calories and will
    help him to lose weight. It contain unique medium chainsaturated fatty acids,
    which are also found in human breast milk. Childhood obesity has become a big issue like obesity in general, the significant increase of young kids and adults who are suffering from obesity is causing elevated concerns about the global health of people in the future, since the
    tendency to develop into an obese person was traditionally regarded as a transfer from overweight at the
    mature stage of life to the obese, but this did not include such high percentages of young adults and kids.

  15. Don’t just give a vague descriptions like, “I just want a new look. Catch up with DISH Network English Packages to cherish the best of American entertainment at a promotional DISH Network offer. As you may have heard on the news recently, some product listings sites on the internet have more than a few problems with merchandise, sources, fraud and more.

  16. Especially, the smartphone will even feature Apple’s new os, i – OS
    7. And that trade-in offer is only good until
    September 30. This will be a scenario inside coming months of June or July 2011 in the event the much acclaimed and eagerly anticipated next generation of
    i – Phone can be released- The Apple i – Phone 5.

Leave a Reply

Your email address will not be published. Required fields are marked *