LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > Install/Configuration > Mapping a subdomain to a folder?

Reply
 
Thread Tools Display Modes
  #1  
Old 09-10-2007, 11:48 AM
apfelKuh apfelKuh is offline
New Member
 
Join Date: Sep 2007
Posts: 1
Question Mapping a subdomain to a folder?

Hi,

I didn't find a solution for this problem in existing threads, so here it goes:

I have two rails virtual hosts running at e.g. www.mydomain.com and blog.mydomain.com.
I would like to have the blog available at www.mydomain.com/blog instead of it being on a subdomain.

How can I achieve this?


Regards
Reply With Quote
  #2  
Old 09-11-2007, 09:57 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
It requires configuration changes in both rails configuration and LSWS configuration, and some rails application simple won't work no matter what, like "typo". There are similar questions asked before, please search on the forum.
Reply With Quote
  #3  
Old 11-03-2008, 01:20 PM
ideaoforder ideaoforder is offline
Member
 
Join Date: Jul 2008
Posts: 28
Default +1 to subdomain mapping

It seems like the question here is whether dispatch.lsapi can accept arguments. In a typical php setup (Ive never had to do this with Rails until now), you can pass arguments like so:

RewriteRule ^(.*)$ index.php?arg=$1 [QSA,L]

So is there a way to pass dispatch.lsapi a controller, action, or namespace?

I understand that this is a complicated issue with many possible responses--but none of the standard Rails ways of handling this allow for a simple silent redirect. This is for a custom app, so I can manage the routes fine and am not worried about breaking anything. I seached the forums and couldn't find a question/answer that addressed this specifically.

Thanks in advance for your time!
Reply With Quote
  #4  
Old 11-03-2008, 02:52 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
You can use rewrite rule to rewrite any URL to /dispatch.lsapi?arg=$1
Internally, LSWS use a 404 not found handler to route request to /dispatch.lsapi, if you explicitly rewrite URL to /dispatch.lsapi, it will override the default.
Reply With Quote
  #5  
Old 11-04-2008, 07:07 AM
ideaoforder ideaoforder is offline
Member
 
Join Date: Jul 2008
Posts: 28
Default Still Unsure

Thank you for your speedy reply! However, I'm still not sure how I would redirect a subdomain to a controller/action/namespace. I understand URL rewriting in general, but am not sure what I need to put specifically. Perhaps an explanation of what I'd like will help:

http://mysubdomain.example.com/controller/action/id

should go to http://example.com/mysubdomain/controller/action/id

In routes.rb I have

map.namespace :mysubdomain do |mysubdomain|
map.resources :mycontroller
end

Thanks again!
Reply With Quote
  #6  
Old 11-04-2008, 07:33 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Are all subdomains handled by the same application? If yes, you need to do the following

setup the rails vhost to serve example.com and all its subdomains, http://mysubdomain.example.com/... will go to this vhost.

then add a rewrite rule by extract the subdomain from HTTP_HOST, then rewrite the URL from /controller/action/id to /mysubdomain/controller/action/id
Reply With Quote
  #7  
Old 11-04-2008, 07:47 AM
ideaoforder ideaoforder is offline
Member
 
Join Date: Jul 2008
Posts: 28
Default Almost There

Yep--all of the subdomains are pointing to the same domain and I have them pointed at the site. I can successfully do a 301 redirect, but my client would like the redirect to be silent. Just redirecting like so:

RewriteCond %{HTTP_HOST} ^mysubsomain.example.com
RewriteRule (.*) http://www.example.com/mysubdomain/$1 [R=301,L]

works fine, but shows the address change.

So I need to know what RewriteRule, specifically will accomplish the above redirect silently.

Something like:

RewriteRule (.*) /mysubdomain/$1

doesn't work. It just produces a 404.

I assume I'd need something like:

RewriteRule (.*) dispatch.lsapi?SOMETHING HERE=$1&NAMESPACE MAYBE=mysubdomain

So I need a concrete example of the rewrite rule. Thanks again!
Reply With Quote
  #8  
Old 11-04-2008, 08:21 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
try the following rewrite rule at vhost level

RewriteCond %{HTTP_HOST} ^mysubsomain.example.com
RewriteRule /(.*) /mysubdomain/$1 [L]

rewrite rule in .htaccess may not work.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:27 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.