【问题标题】:How can I use a wildcard alias for file names in apache config?如何在 apache 配置中使用通配符别名作为文件名?
【发布时间】:2012-03-31 05:24:30
【问题描述】:

当调用以下任一 url 时,我需要 apache 调用 file.php:

  • /file.xml
  • /file-contents.xml
  • /file-abc.xml
  • /file-n.xml
  • /file-xyz.xml

这是我的 apache conf 文件中的一个示例:(倒数第二行是关键行)

<VirtualHost *:80>
    DocumentRoot /html
    ServerName domain.com

    UseCanonicalName Off

    Alias /file.xml /html/file.php
    Alias /file-contents.xml /html/file.php
    Alias /file-*.xml /html/file.php
</VirtualHost>

我可以让 file.xml 和 file-contents.xml 调用 file.php 就好了。但通配符不起作用。

你有什么推荐的?


回答:

感谢马克 B!

AliasMatch ^/file-(.*).xml /html/file.php

【问题讨论】:

    标签: http apache2 apache httpd.conf


    【解决方案1】:

    AliasMatch 允许此类事情的正则表达式:http://httpd.apache.org/docs/2.0/mod/mod_alias.html#aliasmatch

    【讨论】:

      猜你喜欢
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 1970-01-01
      • 1970-01-01
      • 2018-01-24
      • 2016-07-24
      相关资源
      最近更新 更多