2017-12-20 8 views
0

私はYii2の高度なアプリケーションをインストールしました。私は今このURLをhtpp://site/adminのバックエンド(管理者)にリダイレクトすることを試みています。どのような私がこれまで試したことはある: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

イムそうでなければ、それは奉仕するものを知っているdoes'ntはindex.phpサーバーがバックエンドを指す必要があるので、あなたは、Apache/nginxの設定ファイルでそれを行う必要がある恐れ。 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 
関連する問題