2017-12-20 21 views
0

나는 Yii2 고급 앱을 설치했고, 지금은이 URL을 백엔드 (관리자) 측으로 리다이렉트 (redirect)하려고합니다. 무엇 내가 지금까지 시도하는 것입니다 :Yii2 .htaccess가 백엔드 파트로 리다이렉트

AddDefaultCharset utf-8 

Options +FollowSymLinks 
IndexIgnore */* 
RewriteEngine on 


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

# 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 


RewriteRule ^static - [L] 

나는 익숙하지 오순절 .htaccess와 나는 올바른 방법이 무엇인지 확신하지 않다. 이 코드는 인터넷 검색 결과입니다. .htaccess 파일은 app/backend/web/.htaccess에 있습니다. 나에게 옳은 길을 가르쳐 줄 수 있니? 미리 감사드립니다. 쉽게

+1

은 임 두려워 아파치에서 그것을 할 필요가/nginx를 설정 서버가 그렇지 않으면 역할을 알고 does'nt index.php를 백엔드를 가리 키도록해야하기 때문이다. Htaccess는 페이지가 제공된 후에 규칙을 추가 할 수 있습니다. 하위 페이지에 대한 규칙 등 – user2831723

+1

가상 호스트를 사용하여이를 구성해야합니다. – uglypointer

답변

0

:

RewriteEngine On 

# End the processing, if a rewrite already occurred 
RewriteRule ^(frontend|backend)/web/ - [L] 

# Handle the case of backend, skip ([S=1]) the following rule, if current matched 
RewriteRule ^admin(/(.*))?$ backend/web/$2 [S=1] 

# handle the case of frontend 
RewriteRule .* frontend/web/$0 

# Uncomment the following, if you want speaking URL 
#RewriteCond %{REQUEST_FILENAME} !-f 
#RewriteCond %{REQUEST_FILENAME} !-d 
#RewriteRule ^([^/]+/web)/.*$ $1/index.php