Yii2 将Yi2应用程序移动到live server
我已将我的Yii2应用程序从localhost移动到以下位置的live serverYii2 将Yi2应用程序移动到live server,yii2,Yii2,我已将我的Yii2应用程序从localhost移动到以下位置的live server www.mydoamin.com/awpet awpet是应用程序将运行的子域。 另外,我将以下代码作为index.php放在awpet目录中 <?php defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require(__DIR__ . '/vendo
www.mydoamin.com/awpet
awpet是应用程序将运行的子域。
另外,我将以下代码作为index.php放在awpet目录中
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/common/config/bootstrap.php');
require(__DIR__ . '/frontend/config/bootstrap.php');
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/common/config/main.php'),
require(__DIR__ . '/common/config/main-local.php'),
require(__DIR__ . '/frontend/config/main.php'),
require(__DIR__ . '/frontend/config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
?>
如果我遗漏了什么,请告诉我。从index.php中删除您的更改。 打开frontend/config/main.php。 请注意行
'baseUrl'=>'',
注释掉它。
使用:'scriptUrl'=>@$\u服务器['REMOTE\u ADDR']=='127.0.0.1'?'/index.php':'/awpet/index.php'
嗯。我的版本在前端和后端分离
.htaccess在项目的根目录上
# Mod_Autoindex
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# Mod_Rewrite
<IfModule mod_rewrite.c>
Options +SymLinksIfOwnerMatch
RewriteEngine On
IndexIgnore */*
# Open access to storage directory
RewriteRule ^(admin/)?storage/(.+)$ storage/$2 [L,PT]
RewriteRule ^admin/?([^/].*)?$ backend/web/$1 [L,PT]
RewriteRule ^([^/].*)?$ frontend/web/$1
</IfModule>
.htaccess在后端/web上
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
frontend/config/main.php
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
return [
'id' => 'app-frontend',
'name'=>'My AWPET',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module'
],
'workpermit' => [
'class' => 'frontend\modules\workpermit\workpermit',
],
],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => 'advanced-frontend',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
'defaultRoles' => ['guest'],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
// 'urlManager' => [
// 'enablePrettyUrl' => true,
// 'showScriptName' => false,
// 'rules' => [
// ],
// ],
],
'params' => $params,
];
'request' => [
'scriptUrl' => @$_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? '/index.php' : '/awpet/index.php',
'csrfParam' => '_csrf-frontend',
],
'request' => [
'scriptUrl' => @$_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? '/admin/index.php' : '/awpet/admin/index.php',
'csrfParam' => '_csrf-backend',
],
backend/config/main.php
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
return [
'id' => 'app-frontend',
'name'=>'My AWPET',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module'
],
'workpermit' => [
'class' => 'frontend\modules\workpermit\workpermit',
],
],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => 'advanced-frontend',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
'defaultRoles' => ['guest'],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
// 'urlManager' => [
// 'enablePrettyUrl' => true,
// 'showScriptName' => false,
// 'rules' => [
// ],
// ],
],
'params' => $params,
];
'request' => [
'scriptUrl' => @$_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? '/index.php' : '/awpet/index.php',
'csrfParam' => '_csrf-frontend',
],
'request' => [
'scriptUrl' => @$_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? '/admin/index.php' : '/awpet/admin/index.php',
'csrfParam' => '_csrf-backend',
],
据我所知,您的子域awpet.mydomain.com是否指向www.mydoamin.com/awpet 但它不应该指向www.mydoamin.com/awpet/frontend/web吗
www.mydoamin.com。。。应该是服务器路径;例如:/root/www/html/。嗨,valerii,我在main.php中没有'baseUrl'=>''。我在问题中给出了frontend/config/main.php的代码。请检查一下,让我知道。