2

I'm using Apache 2.2x. Most of the content is generated via mod_perl. So, it's dynamic content that has no filesystem mapping. Perfect use of < Location >.

Apache config:

<Location /finance_module1>
  SetHandler perl-script
  PerlResponseHandler Finance::Module1
</Location>

<Location /finance/module2>
  SetHandler perl-script
  PerlResponseHandler Finance::Module2
</Location>

Module1 works, and is shown here to show that my setup otherwise works.

Module2 does not work. Apache says "File does not exist: /home/joe/www/htdocs/finance". The only difference between the module configurations is that Module2 location contains multiple slashes (what I'm calling a nested path).

About the "File does not exist" error: Of course it doesn't exist -- it's a Location, not a File or Directory. So why does this happen?

I would like to be able to use paths with multiple slashes because I've got a lot of mod_perl modules, and it would be nice to categorize for purposes of control. For one trivial instance, robots.txt could simply say:

Disallow: /finance/

The Apache docs specifically state that < Location > directives need not map to the filesystem, and are well-suited for dynamically generated content.

What am I doing wrong? Is there a workaround? (Besides the obvious "just don't do that").

Thanks.

joe
  • 758
  • 1
  • 10
  • 16

2 Answers2

3

Answering my own question, for the benefit of anyone else wondering the same thing.

Short answer, use LocationMatch.

In the example above, say the urls are /finance/module1 and /finance/module2. Having the "finance/" path allows all the finance handlers to be configured as a group, in situations where that's desirable.

For example:

<LocationMatch /finance/.*>
  SetHandler perl-script
  PerlAccessHandler foo
</LocationMatch>

<Location /finance/module1>
  SetHandler perl-script
  PerlResponseHandler Finance::Module1
</Location>

<Location /finance/module2>
  SetHandler perl-script
  PerlResponseHandler Finance::Module2
</Location>
joe
  • 758
  • 1
  • 10
  • 16
0

Slight typo perhaps?

<Location /finance_module1>

vs.

<Location /finance/module2>

Not sure if that is the issue.

Perhaps this (add to httpd.conf)

Alias /finance "path-to-files"
<Directory "path-to-files">
  Options +Indexes
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

Then try the script. You could also make an empty folder there perhaps?

ionFish
  • 1,004
  • 1
  • 8
  • 20
  • Um, no, not a typo. Perhaps I wasn't clear. That's the whole point of the question, hence the "nested path" title. – joe Feb 02 '12 at 04:50
  • Joe, even with your own answer I also think there's a typo in your question, "/finance_module1" versus "/finance/module1". Note the slash/underscore difference. – Reinout van Rees Jan 18 '13 at 14:30
  • No, it's not a typo. I edited the question, and hopefully it's clear now. The whole point is that multiple slashes don't work, eliminating the ability to categorize modules for control and rule purposes. – joe Nov 09 '13 at 21:20