I have a rails application running on my shared host server and the public_html
is mapped to ~/rails_apps/app1/public
.
This was done so www.mydomain.com
launches app1. As expected, the .htaccess is like this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Here comes a new rails app2, and I want to access it through www.mydomain.com/app2
I created ~/rails_apps/app2
, and created the symlink public_html/app2
pointing there (the symlink is actually ~/rails_apps/app1/public/app2
).
This app2 also needs the dispatch.fcgi to launch, so the app2/public/.htaccess
has the same RewriteRules as above.
The problem is that when I access www.mydomain.com/app2/hello
, my first app1 is receiving the request and it's failing. I'm reading this rule as "File /app2/hello doesn't exist, send it to dispatch.fcgi for processing".
So, I tried setting up an additional rule in app1/public
RewriteCond %{REQUEST_URI} ^/app2/.*
RewriteRule ^(.*)$ /app2/dispatch.fcgi [L]
My app2 is now getting the request, but it tries to process /app2/hello
which fails since there is no /app2
defined in my routes. It needs to receive just /hello
.
I also tried putting RewriteBase /app2
just before the rules in the above paragraph, but it didn't开发者_如何学编程 seem to make any difference. I also needed to put RewriteBase /
before the original app1 RewriteRule, otherwise app1 breaks. (sincerely, I don't know if more than one RewriteBase is allowed)
Any ideas how to solve my problem?
to adjust the /app2 routes subdirectory try to add
config.action_controller.relative_url_root = '/app2'
to your environmet.rb (production) ...
hope this could help
精彩评论