I want to have 2 Ruby on Rails applications on a domain.
The first one is running at example.com; I have done that with .htaccess (with RewriteRule to example.com:12001)
I want the other one to be in a subdomain, like blog.example.com. So I created a subdomain, and in the file .htaccess I redirect to example.com:12002.
Everything is working fine, but if I go to address example.com/blog, I am not redirected, and I see in browser the contents of blog folder in public_html:
Index of /blog
Parent Directory
I would like to go to the second application(blog.example.com) when the url is example.com/blog. How could I do that?
the solution depends on how your hosting provider implements multi-subdomain mapping. Some offer a control panel so that you can register your subdomains and point each to a separate subdirectory in your file space. Some will just map
*.yourdomain.zzzto the document root foryourdomain.zzz, and from your description, this is what is happening for you. In this case you need to decode the HTTP_HOST variable and route on that. But you also need to stop your rewrite rule looping so thatsub1.yourdomain.zzzdoesn’t get mapped to yourDocRoot/sub1/sub1/sub1…`If you wanted to process sub1 and sub2 subdomains, then you would do this with a rule in you top level like this:
Search for [.htaccess] HTTP_HOST to see lots of variants of this.