The problem I’m solving here is that I have two different Rails
applicatons
that uses the same domain name. One handles the www (e.g.
www.mycoolapp.com)
and is used as the main site, and the other handles the user subdomains
(e.g… someuser.mycoolapp.com). The DNS stuff and the Apache virtual
hosts
were all set up, the two rails apps are in place in the file system, and
the
proper .fcgi replacements were made in the .htaccess files. The
following
are the configuration details that I applied to test this scenario:
File System:
Main application (www.mycoolapp.com) at /home/user/apps/mainsite
User application (someuser.mycoolapp.com) at
/home/user/apps/usersite
Apache Configuration:
NameVirtualHost *:80
…[other stuff here (e.g FastCgi directives, and etc.)]…
<VirtualHost *:80>
ServerName mycoolapp.com
ServerAlias .mycoolapp.com
DocumentRoot /home/user/apps/mainsite/public
RewriteEngine On
# If the host requested doesn’t begin with www (or no subdomain),
rewrite to usersite directory
RewriteCond %{HTTP_HOST} !^(www.)?mycoolapp.com? [NC]
RewriteRule ^(.)$ /home/user/apps/usersite/public/$1
I could see the main site (www.mycoolapp.com) – it loads up fine. For
the
user site, the rails application error page is displayed, and the
following
entry in my apache error log:
mod_rewrite: maximum number of internal redirects reached. Assuming
configuration error. User ‘RewriteOptions MaxRedirects’ to increase the
limit if necessary.
My erroneous rewrite statements above is the problem. Anyone has ideas
out
there? Thanks.