azi
azi

Reputation: 929

Passenger reading .htaccess from outside rails documentroot

I have a rail3 application running on apache2+phusion_passenger. Everything was working pretty much smoothly till a couple of days back when I suddenly started getting the following error:

[Mon May 13 11:43:16 2013] [error] [client 54.228.16.0] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Mon May 13 11:43:16 2013] [debug] core.c(3063): [client 54.228.16.0] r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /blog/index.php
[Mon May 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected from r->uri = /index.php

Here is how my apache vhost configuration looks like:

<VirtualHost *:80>
    ServerAdmin "[email protected]"
    ServerName analytics.xyz.com
    ServerAlias www.analytics.xyz.com
    MIMEMagicFile /dev/null
    CustomLog logs/analytics_access.log  "%t %>s %b %D %h \"%r\" %u \"%{Referer}i\" \"%{User-Agent}i\""
    ErrorLog logs/analytics_error.log
    LogLevel debug

    DocumentRoot "/home/sysadmin/analytics/public"
    <Directory "/home/sysadmin/analytics/public">
        AllowOverride All
        Options -MultiViews
    </Directory>

</VirtualHost>

After some head scratching, I found that there was a .htaccess lying inside /home/sysadmin which was causing this problem. I removed this file and everything started working again.

Now here is my question. Why is apache/passenger reading a .htaccess file that's not inside the documentroot. There are other vhosts on the system all pointing to diretories /home/sysadmin/specific_dir but none to /home/sysadmin/.

Another thing is that I don't get the same error on my local machine even if I place the same .htaccess file at a similar location.

Upvotes: 2

Views: 995

Answers (1)

Geordee Naliyath
Geordee Naliyath

Reputation: 1859

First of all, thanks for the post. This prompted me to try renaming the .htaccess in home directory and the problem I faced was resolved.

I have now put a rewrite condition in the .htaccess file in home directory as follows.

RewriteCond %{HTTP_HOST} !subdomain.example.com

The issue you faced could be explained by the "Context" as in http://httpd.apache.org/docs/2.2/mod/directive-dict.html#Context

Upvotes: 1

Related Questions