![Apache 2.4 AliasMatch 不起作用](https://linux22.com/image/645867/Apache%202.4%20AliasMatch%20%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我曾经为 /CollabPortal14300 设置过如下别名,效果很好。
Alias /CollabPortal14300 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/
Alias /datacert/api/entity/EmailDocument/\d+/DocumentVersion/1\.0 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/core/html/blank.html
<Directory D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal>
Options Indexes FollowSymLinks Includes ExecCGI
Require all denied
<FilesMatch "\.(gif|jpe?g|jpg|png|js|css|ico)$">
Require all Granted
</FilesMatch>
ExpiresActive On
ExpiresByType image/gif "access plus 10 years"
ExpiresByType image/png "access plus 10 years"
ExpiresByType text/css "access plus 10 years"
ExpiresByType text/javascript "access plus 10 years"
ExpiresByType application/javascript "access plus 10 years"
</Directory>
但是我们尝试从别名中消除数字,并尝试使用 RegEx。因此我切换到 AliasMatch,如下所示
AliasMatch /CollabPortal\d{5} D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/
切换到后无法访问资源D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/
以下是访问日志
fe80::f48e:b1a2:4f75:7c9c - - [12/Nov/2014:15:10:52 -0600] "GET /CollabPortal14300/core/css/styles.css HTTP/1.1" 403 246
fe80::f48e:b1a2:4f75:7c9c - - [12/Nov/2014:15:10:52 -0600] "GET /CollabPortal14300/core/js/lib/jquery.js HTTP/1.1" 403 248
fe80::f48e:b1a2:4f75:7c9c - - [12/Nov/2014:15:10:52 -0600] "GET /CollabPortal14300/core/js/lib/jquery-migrate-1.1.1.js HTTP/1.1" 403 262
fe80::f48e:b1a2:4f75:7c9c - - [12/Nov/2014:15:10:52 -0600] "GET /CollabPortal14300/core/js/lib/jquery-ui.js HTTP/1.1" 403 251
fe80::f48e:b1a2:4f75:7c9c - - [12/Nov/2014:15:10:52 -0600] "GET /CollabPortal14300/core/js/lib/jquery.treeview.js HTTP/1.1" 403 257
fe80::f48e:b1a2:4f75:7c9c - - [12/Nov/2014:15:10:52 -0600] "GET /CollabPortal14300/core/js/lib/jquery.treeview.async.js HTTP/1.1" 403 263
在错误日志中我看到
[Wed Nov 12 15:10:52.846478 2014] [authz_core:error] [pid 42580:tid 916] [client fe80::f48e:b1a2:4f75:7c9c:61108] AH01630: client denied by server configuration:
有人能帮我解决 AliasMatch 为何无法工作吗?
答案1
您没有捕获任何内容,因此您无法将整个 URL 的其余部分附加到第二个参数中的文件系统路径。它不会被隐式捕获和添加。