带有 RewriteRule 和别名 Apache 的 VirtualHost 不工作

VirtualHost with RewriteRule and alias Apache not working

<VirtualHost *:80>
 ServerName abc.example.com
 ServerAlias abc.example.com
 DocumentRoot /var/www/html/abc

 RewriteEngine On
    # If an existing asset or directory is requested go to it as it is
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteCond %{REQUEST_URI} !^/adl/$
    RewriteRule ^ - [L]
    # If the requested resource doesn't exist, use index.html
    RewriteRule ^ /index.html
</VirtualHost>

alias /adl /opt/dl

我有一个这样的虚拟主机设置,它工作得很好。现在我想如果路径中有 /adl 则不应应用重写规则,并且我有一个别名,它指向我的机器目录结构中的路径。

我已经按照下面的方式修复了

<VirtualHost *:80>
 ServerName walton2.biz-motion.com
 ServerAlias walton2.biz-motion.com
 DocumentRoot /var/www/html/fmcg

 RewriteEngine On
 RewriteRule ^/?(adl)($|/) - [L]    
 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
 RewriteRule ^ - [L]
 RewriteRule ^ /index.html
</VirtualHost>

张贴它是因为如果有人遇到这个问题。