0

We're using Apache as a frontend to our web application servers. Apache serves all requests and forwards these requests to the correct application server based on the request URL.

We want to preserve the existing Location-mappings for our single VirtualHost, but forward all other requests to one of the application server for further processing, i.e. we want Apache to forward all requests that do not match any of the existing Location-mappings to a single server. I've tried the following

<VirtualHost *:443>
    # Global settings for virtual host
    ...
    # New "fallback" Location mapping
    <Location />
       ...
    </Location>

    # Existing Location mappings
    <Location /portal>
       ...
    </Location>
    ...
</VirtualHost>

But then Apache forwards all requests to the fallback server. Is there any way to properly specify such a "fallback" Location and still allow existing mappings to function properly?

3 Answers 3

1

Apache reads its config file in a natural way.

Try putting your fallback a bottom of httpd.conf

1
  • Thanks for your response. I have tried defining the '/' Location both at the top of the VirtualHost-definition and at the bottom. It does not appear to make any difference. Perhaps there is a configuration option to specify how Apache should treat/read/interprit the Location-mappings wrt. the ambiguity that occurs, e.g. most specific or least specific? We're running Apache 2.0
    – vingrisen
    Sep 28, 2009 at 14:36
0

I'm not sure if this will work, but you could try pointing the 404 error document to the fallback location.

ErrorDocument 404 /
2
  • wouldn't this still return the HTTP error code to the browser? if so, may negatively impact your SEO
    – Roy Rico
    Sep 28, 2009 at 20:16
  • @Roy Rico: Unfortunately, yes.
    – Powerlord
    Sep 28, 2009 at 20:24
0

I think you could put your directives outside of the directive

NOTE: i'm not at a place where i have access to my apache server to test right now1

<VirtualHost *:443>
    # Global settings for virtual host
    ...

    # New "fallback" Location mapping
    ...

    # Existing Location mappings
    <Location /portal>
       ...
    </Location>

    # Other Settings
    ...
</VirtualHost>

You must log in to answer this question.