Apache(httpd)虚拟主机重写cond变量不工作

Apache(httpd)虚拟主机重写cond变量不工作,apache,mod-rewrite,amazon-web-services,Apache,Mod Rewrite,Amazon Web Services,我试图创建一个动态虚拟主机条目,目的是将所有流量重定向到.mydomain.com到/var/www/html/这部分工作正常,但我还需要一个重写条件来检查目录是否存在,如果不存在,那么我想将所有流量重定向到根/var/www/html/index.php 这部分不起作用,因为在测试期间,我注意到所有重写变量都不起作用,它们都是空的,我无法理解为什么这里是我的虚拟主机配置 # get the server name from the Host: header UseCanonicalName O

我试图创建一个动态虚拟主机条目,目的是将所有流量重定向到.mydomain.com到/var/www/html/这部分工作正常,但我还需要一个重写条件来检查目录是否存在,如果不存在,那么我想将所有流量重定向到根/var/www/html/index.php

这部分不起作用,因为在测试期间,我注意到所有重写变量都不起作用,它们都是空的,我无法理解为什么这里是我的虚拟主机配置

# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
# LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    VirtualDocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
    ServerName vhosts.mydomain.com
    ServerAlias *
    VirtualDocumentRoot /var/www/html/%1

    RewriteEngine on
    LogLevel warn rewrite:trace4

    # If the request is not for a valid directory
    RewriteCond /var/www/html/%1 !-d
    RewriteCond %{REQUEST_FILENAME} !-d
    # If the request is not for a valid file
    RewriteCond %{REQUEST_FILENAME} !-f
    # If the request is not for a valid link
    RewriteCond %{REQUEST_FILENAME} !-l

    RewriteRule .* /var/www/html/index.php

</VirtualHost>

即使%1对虚拟目录的传递很好,但它在mod rewrite规则中不起作用。变量的所有其他用途都会产生相同的结果,任何帮助都将不胜感激。

这是一个更好的问题,与AWS无关。这是在AWS on Amazon Linux build上运行的。在系统中标记AWS之前,我应该在我的描述中指出,我很乐意在这个区域发布int-我不知道还有更好的地方。这是一个更好的问题,与AWS无关。这是在AWS上运行的Amazon Linux build,我应该在系统中标记AWS之前的描述中注意到,我很乐意在这个区域发布int——我不知道有更好的地方。
[Wed Jul 29 16:56:56.015818 2015] [rewrite:trace2] [pid 23898] mod_rewrite.c(475): [client xx.xx.xx.xx:4863] xx.xx.xx.xx - - [fake.mydomain.com/sid#7f5c89bcf570][rid#7f5c89ed5000/initial] init rewrite engine with requested uri /
[Wed Jul 29 16:56:56.016050 2015] [rewrite:trace3] [pid 23898] mod_rewrite.c(475): [client xx.xx.xx.xx:4863] xx.xx.xx.xx - - [fake.mydomain.com/sid#7f5c89bcf570][rid#7f5c89ed5000/initial] applying pattern '.*' to uri '/'
[Wed Jul 29 16:56:56.018361 2015] [rewrite:trace4] [pid 23898] mod_rewrite.c(475): [client xx.xx.xx.xx:4863] xx.xx.xx.xx - - [fake.mydomain.com/sid#7f5c89bcf570][rid#7f5c89ed5000/initial] RewriteCond: input='/var/www/html/' pattern='!-d' => not-matched
[Wed Jul 29 16:56:56.018411 2015] [rewrite:trace1] [pid 23898] mod_rewrite.c(475): [client xx.xx.xx.xx:4863] xx.xx.xx.xx - - [fake.mydomain.com/sid#7f5c89bcf570][rid#7f5c89ed5000/initial] pass through /