0
我在localhost和登臺服務器上設置我的項目。
但是現在我想將我的項目移動到ubuntu
服務器上。
我嘗試了,但是當我試圖找到我的項目它給我The requested URL <PROJECT_NAME>/admin/site/login was not found on this server.
這是我main.php
文件:
在ubuntu上安裝Yii2高級模板
<?php
use \yii\web\Request;
$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')
);
include(__DIR__ . '/constants.php');
include(__DIR__ . '/print_arr_helper.php');
$siteUrl = 'http://**IPADDRESS**/<PROJECT_NAME>/';
return [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'as beforeRequest' => [
'class' => 'yii\filters\AccessControl',
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'allow' => true,
'roles' => ['@'],
],
],
],
'components' => [
'request'=>[
'class' => 'common\components\Request',
'web'=> '/backend/web',
'adminUrl' => '/admin',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => []
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => false,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://localhost:27017/<DB_NAME>',
],
'errorHandler' => [
'errorAction' => 'site/error',
],
],
'params' => $params,
];
?>
這是我.htaacess
文件:
Options +FollowSymlinks
RewriteEngine On
# deal with admin first
RewriteCond %{REQUEST_URI} ^/<PROJRCT_NAME>/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
RewriteCond %{REQUEST_URI} !^/<PROJRCT_NAME>/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} ^/<PROJRCT_NAME>/(admin)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/<PROJRCT_NAME>/(assets|css)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteCond %{REQUEST_URI} !^/<PROJRCT_NAME>/(frontend|backend|ws)/web/(assets|css)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
在backend/
forlders .htaccess
,如果我在URL
中寫入<IPADDRESS>/backend/
,那麼它將重定向到http://<IPADDRESS>/<PROJECT_NAME>/admin/site/login
。
任何人都可以幫忙嗎?