简体   繁体   中英

subdomain for static page in rails 3

I have a Rails 3 app that needs to have subdomains that point to a static page in my code base

EXAMPLE:

mk1.mysite.com needs to show the page that is located

app > views > about > page.html.haml

That page sits at mysite.com/about/page.html

QUESTION:

How can I configure the routes to display the subdirectory ( mysite.com/about/page.html ) page by visiting the subdomain ( mk1.mysite.com )?

I have this in my routes.rb

match '/' => 'about/page.html', :constraints => { :subdomain => 'mk1' }

Where is your regular root route located in your routes file? Is it located before or after the line you listed in your post?

So if you have a line like

root :to => "foo#index" 

In your routes file, above

match '/' => 'about/page.html', :constraints => { :subdomain => 'mk1' }

The root route would be called first and your subdomain route won't be called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM