7

I'm trying to clean up my apache vhosts, since I've got a number of 'Alias's in place, and putting them all into a mod_rewrite can be annoying. However, while I can get to specific URLs (such as http://example.dev/robots.txt, http://example.dev/ on its own, the vhost will not fall back to the listed URL (FallbackResource /index.php).

The vhost is a container for a Zend Framework project, and no .htaccess files are set.

The access log shows .... "GET / HTTP/1.1" 302 0, but Google Chrome is showing 'No data received' and 'Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.'

Commenting out the FallbackResource line, and re-enabling the <Location />-based mod_rewrite works as expected though.

EDIT: There is nothing in the vhost that I can see to stop it from working. A few Alias lines (which FallbackResource is supposed to work with) and some FilesMatch to stop access to file with particular extensions. The only thing appearing in the logs is the 404 when it's trying to go to the URL and not to index.php (the listed resource).

<VirtualHost *:80>
    ServerAdmin webmaster@site.com
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /var/website/current/html/

    SetEnv APPLICATION_ENV productionbackend

    # must be most specific first
    Alias /i/static /var/website/static/i
    # more /i/* Alias
    Alias /i       /var/website/current/resources/common-furniture/

    # protecting files in the directory.
    <FilesMatch ".*\.xml">
        Order allow,deny
        Deny from all
    </FilesMatch>

    <Directory "/var/website/current/html/">
        Options FollowSymLinks All
        AllowOverride All
    </Directory>

    ErrorLog  logs/error.log
    CustomLog logs/access.log common
</VirtualHost>
Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
  • Anything in the Apache error logs? – nneonneo Aug 25 '12 at 03:52
  • Is there any directive in your vhost that may prevent FallbackResource to work ? Please post a larger section of your vhost configuration. – Yves Martin Aug 25 '12 at 06:02
  • I'm also having the same problem. My vhost is ultra simple [pasted here](http://pastebin.com/Z4PMa7gx) and my htaccess only contains `FallbackResource index.html`. Perhaps you solved this @Marlun? – Philip Bulley Sep 12 '13 at 11:03

1 Answers1

4

I have a solution. As I said in my comment on the original question, I'm also having the same problem. My vhost is ultra simple:

<VirtualHost *:8029>
    DocumentRoot "C:\path\to\wwwroot"
    ServerName localhost
        <Directory />
                AllowOverride All
        </Directory>
</VirtualHost>

and my htaccess only contains:

FallbackResource index.html

I have added DirectoryIndex to my .htaccess file. It now reads:

FallbackResource /index.html
DirectoryIndex index.html

This has solved the problem.

Why does this work?

The empty response only occurred when the / url was called the second time and it was cached by the browser. For some reason, it seems that FallbackResource fails in this instance, so I figured that by ensuring that the index.html is served via specifying DirectoryIndex, there would be no need for a fallback. You could call this a workaround.

Philip Bulley
  • 9,014
  • 3
  • 33
  • 46
  • 2
    This answer is bad on a number of fronts: First off you're setting `AllowOverride All` in `` -- that means you are not only allowing user defined configs EVERYWHERE, you're also instructing httpd to check for it EVERYWHERE. This has HUGE performance AND security implications. Then, despite having complete access to the configuration, you're using putting part of your config into a `.htaccess`: I'd like to reiterate that this is only useful for *users* who do *not* (and *should* not have) access to the server or its configuration. – Mina Galić Sep 27 '13 at 22:14
  • 1
    Right you are @IgorGalić :) I should have noted that this is a dev solution only as my `.htaccess` is conveniently under VCS and my system wide `httpd-vhosts.conf` is not. I'll be putting my config into the `httpd-vhosts.conf` on the actual deploy. Thanks for commenting. – Philip Bulley Oct 02 '13 at 14:05