Yii2无法到达后端部分

时间:2017-10-07 09:28:50

标签: yii2-advanced-app

我真的不明白我怎么才能到达后端..我如何安装高级模板就像他们在官方网站上显示它的方式:http://www.yiiframework.com/download/。一切都在循序渐进。当我尝试frontend.dev(在我的情况下eshop)时,我被重定向到前端部分但是当我尝试backend.dev(在我的情况下eshop/admin)时,我也被重定向到前端。 这是我的主机文件:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
#   127.0.0.1       modules
127.0.0.1       eshop
127.0.0.1       eshop/admin

0.0.0.1 mssplus.mcafee.com

vhost.conf:

<VirtualHost *:80>
    ServerName eshop
    DocumentRoot "C:/xampp/htdocs/eshop/frontend/web/"

    <Directory "C:/xampp/htdocs/eshop/frontend/web/">
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php

        # use index.php as index file
        DirectoryIndex index.php

        # ...other settings...
        # Apache 2.4
        Require all granted

        ## Apache 2.2
        # Order allow,deny
        # Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName eshop/admin
    DocumentRoot "C:/xampp/htdocs/eshop/backend/web/"

    <Directory "C:/xampp/htdocs/eshop/backend/web/">
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php

        # use index.php as index file
        DirectoryIndex index.php

        # ...other settings...
        # Apache 2.4
        Require all granted

        ## Apache 2.2
        # Order allow,deny
        # Allow from all
    </Directory>
</VirtualHost>

我的错误在哪里?非常感谢提前!

1 个答案:

答案 0 :(得分:1)

在主机名中使用斜杠(/)是非法的,因为它在RFC 952中定义。因此,在网址&#34; http://eshop/admin&#34;服务器名称是&#34; eshop&#34;和apache当然是你的第一个虚拟服务器设置。 总而言之,您的想法永远不会奏效。您应该使用eshop-admin作为服务器名称。