别名在虚拟主机中工作不正确

别名在虚拟主机中工作不正确

问题描述:

I have defined such virtual host on a local Apache server.

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/wamp/www/yii/frontend/web"
    <Directory "c:/wamp/www/yii/frontend/web">
    AllowOverride all
    Require all granted
    </Directory>
    Alias /admin "c:/wamp/www/yii/backend/web"
    <Directory "c:/wamp/www/yii/backend/web">
    AllowOverride all
    Require all granted
    </Directory>
    ServerName florist
    ErrorLog "logs/yii-error.log"
    CustomLog "logs/yii-access.log" common
</VirtualHost>

URL http://florist/admin works correctly and processed by /backend/web/index.php.

But URL http://florist/admin/login have processed by /frontend/web/index.php

I found this out when I placed exit() function with appropriate message in appropriate index.php

What's wrong may be in the alias?

我在本地Apache服务器上定义了这样的虚拟主机。 p>

 &lt; VirtualHost *:80&gt; 
 ServerAdmin webmaster@dummy-host2.example.com 
 DocumentRoot“c:/ wamp / www / yii / frontend / web”
&lt; Directory“c:/ wamp / www  / yii / frontend / web“&gt; 
 AllowOverride all 
需要全部授予
&lt; /目录&gt; 
别名/ admin”c:/ wamp / www / yii / backend / web“
&lt;目录”  c:/ wamp / www / yii / backend / web“&gt; 
 AllowOverride all 
需要全部授予
&lt; / Directory&gt; 
 ServerName花店
 ErrorLog”logs / yii-error.log“
 CustomLog  “logs / yii-access.log”common 
&lt; / VirtualHost&gt; 
  code>  pre> 
 
 

URL http:// florist / admin 正常工作并由/backend/web/index.php.

nnn

处理URL http:// florist / admin / login 已由/frontend/web/index.php处理 p>

当我在适当的index.php中使用适当的消息放置exit()函数时,我发现了这一点。 p>

别名可能有什么问题? p>

I have created simlink to c:\wamp\www\yii\backend\web

mklink /D c:\wamp\www\yii\frontend\web\admin c:\wamp\www\yii\backend\web

and add Options FollowSymLinks in the virtual host definition. It's resolve a problem.

Try add .htaccess in admin subfolder:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php