(1) 文件夹结构
~/public_html/
~/public_html/plan
~/public_html/blog
其中plan和blog是两个独立的rails项目
(2) .htaccess 文件的配置
~/public_html/plan/.htaccess
RewriteEngine On
RewriteRule ^(.*)$ ./public/$1 [L]
~/public_html/plan/public/.htaccess
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
(3)plan项目路由配置 routes.rb
1. ActionController::Routing::Routes.draw do |map|
2.
3.
4. #for user login/logout
5. map.activate '/plan/activate/:activation_code', :controller => 'users', :action => 'activate'
6. map.signup '/plan/signup', :controller => 'users', :action => 'new'
7. map.login '/plan/login', :controller => 'sessions', :action => 'new'
8. map.logout '/plan/logout', :controller => 'sessions', :action => 'destroy'
9. map.resources :users,:as=>"plan/users"
10. map.resource :session,:as=>"plan/session"
11. #end of user login/logout
12.
13.
14.
15. #map.resources 'projects/all',:controller=>"projects",:action=>'tasks'
16. map.resources :projects, :has_many=>:comments,:as=>"plan/projects"
17. map.resources :projects, :has_many=>:tasks,:as=>"plan/projects"
18.
19. #map.connect 'tasks/all', :controller => 'tasks', :action => 'list'
20.
21.
22. map.root :controller=>"projects"
23. map.connect '/plan/:controller/:action'
24. map.connect '/plan/:controller/:action/:id'
25. map.connect '/plan/:controller/:action/:id.:format'
26. end