2017-12-06 15 views
1

은 내가 frontendbackend 모두 별도 만들고 싶어 YII 1.1특정 파일에 대해 가상 호스트를 설정하는 방법은 무엇입니까?

에서 응용 프로그램을 개발하고있다. 여기 문서 : Yii 1.1: Organize directories for applications with front-end and back-end using WebApplicationEnd behavior

나는이 개 내 루트 index.php에서 파일과 admin.php

내가 frontend.dev 통해 index.php 파일 액세스 및 backend.dev

코드를 통해 admin.php 파일 액세스하려는 있습니다

<VirtualHost *:80> 
    ServerName frontend.dev 
    DocumentRoot "C:\xampp\htdocs\myproject" 
    <Directory "C:\xampp\htdocs\myproject"> 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName backend.dev 
    DocumentRoot "C:\xampp\htdocs\myproject" 
    <Directory "C:\xampp\htdocs\myproject"> 
     AllowOverride All 
     Order allow,deny 
     Allow from all 

     RewriteEngine on 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule . admin.php 
     DirectoryIndex admin.php 
     Require all granted 
    </Directory> 
</VirtualHost> 

하는 경우를 나는 http://backend.dev을 열었다. 내 기본 admin.php 가상 DirectoryIndex에서 설정 작업. 하지만 http://backend.dev/post/test과 같은 다른 컨트롤러와 동작에 액세스 할 때이 URL은 index.php 파일에 액세스합니다. 그것을 관리하는 방법?

편집을 도와주세요 :

AddDefaultCharset utf-8 

Options +FollowSymLinks 
IndexIgnore */* 
RewriteEngine on 

# Make the backend accessible via url: http://site/backend. 
RewriteRule ^admin admin.php 

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

admin.php를 admin/backend라는 디렉토리 아래에두면 문제가 해결 될 것이라고 생각합니다. –

+0

@YunusSaha admin 또는 backend라는 디렉토리가 없습니다. – Developer

+0

.htaccess 파일이 있습니까? –

답변

0

당신의 가상 호스트 파일

<VirtualHost *:80> 
    ServerName frontend.dev 
    DocumentRoot "C:\xampp\htdocs\myproject" 
    <Directory "C:\xampp\htdocs\myproject"> 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName backend.dev 
    DocumentRoot "C:\xampp\htdocs\myproject" 
    <Directory "C:\xampp\htdocs\myproject"> 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

에 갈 수 다음과 당신의 .htaccess 파일에 갈 수있는 다음과 같습니다.

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{HTTP_HOST} ^frontend.dev 
RewriteRule ^(.*) index.php [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{HTTP_HOST} ^backend.dev 
RewriteRule ^(.*) admin.php [L] 

통지이 올바르게 각각의 파일에 도메인의 요청을 전달합니다 RewriteCond %{HTTP_HOST} ^frontend.devRewriteCond %{HTTP_HOST} ^backend.dev

.