当调用以下任一网址时,我需要 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/