2016-05-05 6 views

答えて

0

あなたのプロジェクト名/ウェブ/ .htaccessファイルに以下を追加apacheのための基本的なテンプレート

$config = [ 
    //... 
    'components' => [ 
     'urlManager' => [ 
      'class' => 'yii\web\UrlManager', 
      'showScriptName' => false, 
      'enablePrettyUrl' => true, 
     ], 
     //... 

に/web.phpの(高度なテンプレートで)アプリ/設定/ main.phpではかなりのURLを有効にする必要があります

Options +FollowSymLinks 
IndexIgnore */* 

RewriteEngine on 
RewriteBase /ProjectName/ 
# 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?r=$1 [L,QSA] 

を使用すると、ディレクトリ構造以下の持っていると言うより Enable clean URL in Yii2

0

レッツのためにこれを参照してください。

/root 
| 
|--/logs // or any other folder 
|--/html <-- this is where DOMAIN.com is pointing 
    | 
    |--/ProjectName 
     | 
     |--/assets 
     |--/web 
     |--// and other folder 

できることは、プロジェクトフォルダをhtmlの外に移動することです。 htmlフォルダ内にアプリのwebフォルダのみをコピーし、ProjectName(または他のもの)に名前を変更します。

/root 
| 
|--/logs // or any other folder 
|--/html <-- this is where DOMAIN.com is pointing 
    | 
    |--/ProjectName 
     | 
     |--/assets 
     |--/css 
     |--/index.php <-- EDIT this one 
     |--// and other files you had in web folder 
|--/ProjectName 
    | 
    |--/assets 
    |--/web 
    |--// and other folder 

ついにindex.phpを開きます(ファイルは上記の指摘)、次の行に置き換えます:これで

require(__DIR__ . '/../vendor/autoload.php'); 
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); 

$config = require(__DIR__ . '/../config/web.php'); 

$project_path = __DIR__ . '/../../PojectName'; 

require($project_path . '/vendor/autoload.php'); 
require($project_path . '/vendor/yiisoft/yii2/Yii.php'); 

$config = require($project_path . '/config/web.php'); 

それだ今、あなたのフォルダ構造は次のようになります。 。今すぐにあなたのアプリケーションにアクセスすることができます:http://DOMAIN/ProjectName

希望に役立ちます。コメントに私に知らせていない場合。

関連する問題