简体   繁体   English

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

[英]Alias incorrect working in a virtual host

I have defined such virtual host on a local Apache server. 我已经在本地Apache服务器上定义了这样的虚拟主机。

<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. URL http:// florist / admin可以正常工作,并由/backend/web/index.php处理。

But URL http://florist/admin/login have processed by /frontend/web/index.php 但是URL http:// florist / admin / login已由/frontend/web/index.php处理

I found this out when I placed exit() function with appropriate message in appropriate index.php 我在适当的index.php中放置带有适当消息的exit()函数时发现了这一点

What's wrong may be in the alias? 别名有什么问题?

Try add .htaccess in admin subfolder: 尝试在admin子文件夹中添加.htaccess:

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

I have created simlink to c:\\wamp\\www\\yii\\backend\\web 我已经创建了到c:\\wamp\\www\\yii\\backend\\web simlink

mklink /D c:\\wamp\\www\\yii\\frontend\\web\\admin 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. 并在虚拟主机定义中添加Options FollowSymLinks It's resolve a problem. 解决了一个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM