具有RewriteRule和别名Apache的VirtualHost不起作用



<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>

发布它是因为如果有人面临这种情况。

相关内容

最新更新