Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7012321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:14:25+00:00 2026-05-27T22:14:25+00:00

I have 2 subdomains that point to one rails application. My rails application’s controllers

  • 0

I have 2 subdomains that point to one rails application. My rails application’s controllers should serve both subdomains.

Lets call the subdomains http://www.mydomain.com and demo.mydomain.com. I want 2 to accomplish 3 things:

  1. Make sure only some of my controllers serve http://www.mydomain.com and some serve both domains.
  2. Make sure only a subset of my controllers’ actions serve http://www.mydomain.com and some serve both domains.
  3. Make sure users use only format :html for demo.mydomain.com (e.g. http://demo.mydomain.com/index.html) and use only formats :json/:xml for http://www.mydomain.com (e.g. http://www.mydomain.com/index.json).

What’s the best way to accomplish both requests ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:14:26+00:00Added an answer on May 27, 2026 at 10:14 pm

    Perhaps take a look at request routing based on subdomain

    How do I route by domain / subdomain in rails

    http://agilewebdevelopment.com/plugins/request_routing

    where the request_routing plugin would allow you to define routing requirements that test methods/properties of the request object such as subdomain, domain, port. You can test them either against a value or with a Regexp (assuming the method returns a string).

    If you’re using rails 3 you could also check out subdomaining your rails site

    http://railscasts.com/episodes/221-subdomains-in-rails-3

    In order to get your controllers to respond differently based on subdomain, you can use a conditional based on

    @host = request.host
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that lets users get a *.onemobi.net account (ex. bob.onemobi.net ).
I am building a site in asp.net and have multiple subdomains. For example, one.cookies.com
I have modified my etc/hosts file (under Windows 7), so that www.example.com and demo.example.com
I am currently building an application that I will host and will have multi-tenants
Is it possible to have one php page that uses a switch to show
I am developing a website using Codeigniter that will have different subdomains for different
I'm working on one multi-tenancy application, where each tenant will have access to 1
I have a subdomain m.example.com that I want to point to the same location
I have a server that I am setting up to rewrite subdomains as get
I have a subdomain that need to point to a folder inside the public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.