Answer the question
In order to leave comments, you need to log in
How to fix the error: Internal Server Error (Yii advanced)?
In the main directory, I created a .htaccess file with the given codes in the inside:
# prevent directory listings
Options -Indexes
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/admin/$
RewriteRule ^(admin)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} ^.*$
RewriteRule ^(.*)$ /frontend/web/$1
# use mod_rewrite for pretty URL support
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php
Answer the question
In order to leave comments, you need to log in
See apache logs.
But it's better to move the contents of frontend/web to the root of the public folder, create a subdomain for the backend and move the contents of backend/web there. And throw everything else into the "yii" folder and raise it to a level above the public folder. At the same time, .htaccess will not have to be tortured, this is enough:
RewriteEngine on
# hide files and folders
RedirectMatch 404 /\.git
RedirectMatch 404 /composer\.
RedirectMatch 404 /.bowerrc
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
<?php
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
require(__DIR__ . '/../yii/vendor/autoload.php');
require(__DIR__ . '/../yii/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../yii/common/config/bootstrap.php');
require(__DIR__ . '/../yii/frontend/config/bootstrap.php');
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../yii/common/config/main.php'),
require(__DIR__ . '/../yii/common/config/main-local.php'),
require(__DIR__ . '/../yii/frontend/config/main.php'),
require(__DIR__ . '/../yii/frontend/config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question