2

我正在使用 Apache 2.2x。大部分内容是通过 mod_perl 生成的。因此,它是没有文件系统映射的动态内容。完美利用<位置>。

阿帕奇配置:

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

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

Module1 有效,此处显示以表明我的设置在其他方面有效。

模块 2 不起作用。Apache 说“文件不存在:/home/joe/www/htdocs/finance”。模块配置之间的唯一区别是 Module2 位置包含多个斜杠(我称之为嵌套路径)。

关于“文件不存在”错误:当然它不存在——它是一个位置,而不是文件或目录。那么为什么会这样呢?

我希望能够使用带有多个斜杠的路径,因为我有很多 mod_perl 模块,并且出于控制目的进行分类会很好。举一个简单的例子,robots.txt 可以简单地说:

Disallow: /finance/

Apache 文档明确指出 < Location > 指令不需要映射到文件系统,并且非常适合动态生成的内容。

我究竟做错了什么?有解决方法吗?(除了明显的“不要那样做”)。

谢谢。

4

2 回答 2

3

回答我自己的问题,以帮助其他想知道同样事情的人。

简短的回答,使用 LocationMatch。

在上面的示例中,假设 url 是 /finance/module1 和 /finance/module2。在需要的情况下,拥有“finance/”路径允许将所有财务处理程序配置为一个组。

例如:

<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>
于 2012-03-06T04:15:01.040 回答
0

可能是轻微的错字?

<Location /finance_module1>

对比

<Location /finance/module2>

不确定这是否是问题所在。

也许这个(添加到 httpd.conf)

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

然后尝试脚本。你也可以在那里创建一个空文件夹?

于 2012-02-02T03:46:25.980 回答