2017-10-07 89 views
0

我真的不明白它如何才能到達後端..我如何安裝高級模板就像他們在官方站點顯示它的方式:http://www.yiiframework.com/download/。一切都一步一步來。當我嘗試frontend.dev(在我的案例eshop)我重定向到前端部分,但是當我嘗試backend.dev(在我的案例eshop/admin)我也重定向到前端。 這是我的主機文件:Yii2無法到達後端部分

# 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> 

哪裏是我的錯?提前致謝!

+0

Yii2高級模板[使用Composer安裝](https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md)。 – vishuB

+0

預計'eshop/admin'被識別爲'eshop'前端和'admin'作爲控制器。嘗試將vhost設置爲「admin.eshop」或其他。 – Yupik

+0

是的,它的工作原理是如果分隔符是一個點(。),但是使其成爲斜線(/)的正確方法是什麼?我應該在'.htaccess'文件中添加一些更改嗎? –

回答

1

在主機名中使用斜槓(/)是非法的,因爲它在RFC 952中定義。因此,在URL「http://eshop/admin」中,服務器名稱是「eshop」,而apache當然使用您的第一個虛擬服務器設置。總結,你的想法永遠不會工作。您應該使用eshop-admin作爲服務器名稱。