Apache AliasMatch 和 DirectoryMatch 不工作?

Apache AliasMatch 和 DirectoryMatch 不工作?

我有以下配置 - 请注意别名和目录等效 - 取消注释它们按预期工作,但基于动态/正则表达式的版本却没有 - 有什么想法吗???

<VirtualHost *:80>

  ServerName  temp.dev.local
  ServerAlias temp.dev.local
  DocumentRoot "C:\wamp\www\temp\public"

  <Directory "C:\wamp\www\temp\public">
    AllowOverride all
    Order Allow,Deny
    Allow from all
  </Directory>

  # Alias /private/application/core/page/assets/images/ "C:/wamp/www/temp/private/application/core/page/assets/images/"
  # <Directory "C:/wamp/www/temp/private/application/core/page/assets/images/">

  AliasMatch ^/private/application/(.*)/(.*)/assets/images/ /private/application/$1/$2/assets/images/
  <DirectoryMatch "^/private/application/(.*)/(.*)/assets/images/">
    Options Indexes FollowSymlinks MultiViews Includes
    AllowOverride None
    Order allow,deny
    Allow from all
  </DirectoryMatch>

</VirtualHost>

答案1

那里AliasMatch根本没有改变路径——我猜那不是故意的?

AliasMatch ^/private/application/(.*)/(.*)/assets/images/ /private/application/$1/$2/assets/images/

改成:

AliasMatch ^/private/application/([^/]*)/([^/]*)/assets/images/ "C:/wamp/www/temp/private/application/$1/$2/assets/images/"

另外:我交换了.*s 以避免匹配/,以避免无意中击中匹配项。

您的DirectoryMatch还包含 URL 路径,而不是文件系统路径。它可能只是:

<Directory "C:/wamp/www/temp/private/application/">

LocationMatch但是,如果您愿意的话,那里的配置会非常适合:

<LocationMatch "^/private/application/[^/]*/[^/]*/assets/images/">

相关内容