I’m using VestaCP as my control panel, I have installed Yii Advanced application template, and put this configurations on my httpd.conf:
<VirtualHost 176.xx.xx.xx:8080>
ServerName domain.com
ServerAlias www.domain.com subdomain.domain.com
ServerAdmin info@domain.com
DocumentRoot /home/admin/web/domain.com/public_html/frontend/web
ScriptAlias /cgi-bin/ /home/admin/web/domain.com/cgi-bin/
Alias /vstats/ /home/admin/web/domain.com/stats/
Alias /error/ /home/admin/web/domain.com/document_errors/
Alias /backend/ /home/admin/web/domain.com/public_html/backend/web/
#SuexecUserGroup admin admin
CustomLog /var/log/httpd/domains/domain.com.bytes bytes
CustomLog /var/log/httpd/domains/domain.com.log combined
ErrorLog /var/log/httpd/domains/domain.com.error.log
<Directory /home/admin/web/domain.com/public_html/frontend/web>
AllowOverride All
Options +Includes -Indexes +ExecCGI
</Directory>
<Directory /home/admin/web/domain.com/stats>
AllowOverride All
</Directory>
<Directory /home/admin/web/domain.com/public_html/backend/web>
AllowOverride All
Options +Includes -Indexes +ExecCGI
</Directory>
<IfModule mod_ruid2.c>
RMode config
RUidGid admin admin
RGroups apache
</IfModule>
<IfModule itk.c>
AssignUserID admin admin
</IfModule>
Include /home/admin/conf/web/httpd.domain.com.conf*
</VirtualHost>
When I have enablePrettyUrl set to false I am able to access the website through the links:
frontend - domain.com
backend - domain.com/backend
Then I turn on enablePrettyUrl on frontend/config/main.php and backend/config/main.php:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
On frontend everything works great but if I try to acsess domain.com/backend I am redirected to domain.com/backend/site/login that gives me a 404 error, the server is trying to get the website from the
frontend/web folder instead of using the backend/web folder
This is my htaccess in both frontend and backend:
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
Someone have any clue?
Note: If I turn off enablePrettyUrl on the backend main.php file, if I visit domain.com/backend I was redirected to backend/index.php?r=site/login and it works…