Mod重写虚拟主机和Zend

时间:2011-11-20 17:33:12

标签: zend-framework mod-rewrite virtualhost

我的Apache配置:

DocumentRoot /var/www
<VirtualHost *:80>
    Alias /T "/var/www/Test"
    <Directory /var/www/Test>   
        Options Indexes FollowSymLinks MultiViews
        #AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost>

<VirtualHost *:80>
    SetEnv APPLICATION_ENV "development"
    Alias /N "/var/www/NCAA/public"
    <Directory /var/www/NCAA/public>        
        Options Indexes FollowSymLinks MultiViews
        AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/var/www/NCAA/public中的.htacess文件:

RewriteEngine On
RewriteBase   /N/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我可以转到localhost / T中的文件,但我得到/ stronghost / N的 404 我在我的apache日志中得到了这个:

[Sun Nov 20 16:32:37 2011] [error] [client 127.0.0.1] File does not exist: /var/www/N

所以我不确定我做错了什么。我希望1个域名成为具有别名的常规域名,另一个域名是Zend应用程序,其中index.php

具有mod重新归档

由于

1 个答案:

答案 0 :(得分:0)

您真的需要在http://localhost/N下访问NCAA应用吗?是否可以在不同的网址下访问它,例如http://local.ncaa/

如果是这样,那么虚拟主机条目可能如下所示:

<VirtualHost *:80>
    DocumentRoot /var/www/NCAA/public
    ServerName local.ncaa
    SetEnv APPLICATION_ENV development
    <Directory /var/www/NCAA/public>        
        Options Indexes FollowSymLinks MultiViews
        AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

然后可以使用标准ZF .htaccess(不需要重写基础):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]