LS Dynamic Subdomains / Request_Routing

Discussion in 'Ruby/Rails' started by mway, Dec 25, 2007.

  1. mway

    mway Member

    I have request_routing installed, and as far as I can tell there shouldn't be too much tweaking required from the plugin end to parse for subdomains, however, it doesn't work.

    My .ls_rails_config is set up (and working) per default settings, as such:
    RailsApp myapp "/rails_site_folder" "production" 4 1
    RailsAppMap myapp "" "/"
    I understand that the point of routing, etc is to replace mod_rewrite, but a) do I need to include wildcards for the subdomains in .ls_rails_config; b) need to do some kind of application tweak to parse subdomains properly; c) something else?

    I'm on a shared server, and I don't really have much LS admin experience, so I don't know whether I need my host to enable something for me.

    The point, essentially, is to route subdomains dynamically to a particular url/param (eg, routes to

    Any thoughts? Sorry for my lack of expertise. :)
  2. mistwang

    mistwang LiteSpeed Staff

    You need to make sure the vhost "" configured in your control panel to handle subdomains as well. add "" as an domain alias for the vhost.

    Route subdomain dynamicially to a URL can be done via URL rewrite, same as what you would do with Apache.
  3. mway

    mway Member

    Thanks, that was a lot of help.

    I have the rewrite working properly for the most part, and this is a little off-topic, but maybe someone knows the answer off the top of their head:

    Part of my .htaccess looks like this:

    RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.com
    RewriteRule (.*) /redirect.php?s=%1 [L]
    I want to add another wildcard, though, and parse not only the subdomain, but anything after the domain as well, so that (for example):

    rewrites to:


    I'm alright with regex but maybe using it in rewrites is just phasing me.

    I've done this:

    RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.com
    RewriteRule (.*)\.mysite\.com(.*) /redirect.php?s=%1%2 [L]
    but that doesn't seem to work. Any quick tips for getting RewriteRule to use both wildcards?
  4. mistwang

    mistwang LiteSpeed Staff

    RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.com
    RewriteRule (.*) /redirect.php?s=%1&q=$1 [L]

Share This Page