http - 如何在 apache 配置中使用通配符别名作为文件名?

标签 http apache2 apache httpd.conf

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

  • /文件.xml
  • /文件内容.xml
  • /file-abc.xml
  • /file-n.xml
  • /文件-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

最佳答案

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

关于http - 如何在 apache 配置中使用通配符别名作为文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9707267/

相关文章:

java - TargetAuthenticationStrategy,更改优先顺序

c# - VLC Media Player 如何实现 HTTP Streaming?

http - WebTest 工作但 LoadTest 不工作

http - 如何知道使用什么端口从 Postman 发出 http Get 请求

php - "(include_path=' 是什么意思。 :/usr/share/pear:/usr/share/php')"?

python-2.7 - 我的 Apache WSGI Flask 网络应用程序无法导入其内部 python 模块

php - 浏览器从 apache 网络服务器下载 php 文件

PHP:非阻塞shell_exec WITH命令输出

apache - Kubernetes:无法使用apache和https部署Flask Web应用

javascript - AJAX 使用或支持哪些 HTTP 方法?