I'm trying to get an Yii2 advanced template up on a VPS. Everything works fine in terms of algorithms and pathing until I try to enable 'pretty url' through config files and .htaccess. It works perfectly for /frontend, but /backend can no longer be accessed. I'm still a newbie on .htaccess so any help would be appreciated.
Root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule backend backend\.php [T=application/x-httpd-php]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
common\config\main.php (urlManager)
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
frontend/web/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
I've also tried changing the frontend/config/main.php basePath as such:
use yii\web\Request;
$baseUrl = str_replace('/frontend/web', '', (new Request)->getBaseUrl());
But to no avail, since I would only get a 500 error (and nothing else) while trying to access the server.
Note: mode_rewrite has been enabled both through a2enmod and through apache2.conf.