S
S
Sergey Zolotarev2022-02-07 08:19:59
PHP
Sergey Zolotarev, 2022-02-07 08:19:59

How to get rid of Yii2 500 error after migrating to hosting?

Good morning!

I recently published the files of a Yii2 site without a hosting project and encountered a 500 error when accessing the root folder by domain.

Since, thanks to popular articles on the correct configuration of Yii2, everything was configured correctly. This allegedly caused a problem. How to solve it so that the site itself can be launched on a hosting?

Project structure in hosting domain (Linux ls command):

assets           commands    composer.json  config       InvestPortal.geany  models            runtime  vagrant  views  widgets  yii.bat
codeception.yml  components  composer.lock  controllers  mail                requirements.php  tests    vendor   web    yii


Examples of problematic access configuration in Yii2:
/web/index.php

<?php

// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require '../vendor/autoload.php';
require '../vendor/yiisoft/yii2/Yii.php';

$config = require '../config/web.php';

(new yii\web\Application($config))->run();


/.htaccess

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

/web/.htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-02-07
@seregazolotaryow64

100500 times it is said that the 500 error does not tell us anything, see the web server logs. This is the first action with such that for php, that for the rest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question