【问题标题】:Mod rewrite virtual host and ZendMod重写虚拟主机和Zend
【发布时间】:2011-11-20 17:33:12
【问题描述】:

我的 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 中的文件,但是对于 /localhost/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 重写

谢谢

【问题讨论】:

    标签: zend-framework mod-rewrite virtualhost


    【解决方案1】:

    您真的需要在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了(不需要rewrite base):

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

    【讨论】:

      猜你喜欢
      • 2013-11-17
      • 2014-05-14
      • 2014-08-06
      • 2016-06-30
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      相关资源
      最近更新 更多