yii2-advanced-one-domain-config
yii2-advanced-one-domain-config copied to clipboard
Inside subdirectory
How should I to configure my .htaccess if I need to run the app advanced inside a subdirectory to access to it as web subdirectory, e.g: www.mysite.tld/app-advanced ?
Hi.
Your virtual host configuration should be like follow that:
<VirtualHost *:80>
ServerName 0.0.0.0
DocumentRoot /home/app
<Directory />
DirectoryIndex index.html
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Create and edit the application files. The /home/app/yii2-app-advanced/.htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^
RewriteRule ^ frontend/web%{REQUEST_URI}
RewriteRule /admin backend/web%{REQUEST_URI}
The /home/app/yii2-app-advanced/frontend/web/.htaccess and /home/app/yii2-app-advanced/backend/web/.htaccess files:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
The /home/app/yii2-app-advanced/frontend/config/main.php file:
'homeUrl' => '/yii2-app-advanced',
'components' => [
'request' => [
'baseUrl' => '/yii2-app-advanced',
],
'assetManager' => [
'baseUrl' => '/yii2-app-advanced/frontend/web/assets',
],
...
The /home/app/yii2-app-advanced/backend/config/main.php file:
'homeUrl' => '/yii2-app-advanced/admin',
'components' => [
'request' => [
'baseUrl' => '/yii2-app-advanced/admin',
],
'assetManager' => [
'baseUrl' => '/yii2-app-advanced/backend/web/assets',
],
...
Also modify the /home/app/yii2-app-advanced/frontend/assets/AppAsset.php and /home/app/yii2-app-advanced/backend/assets/AppAsset.php files: the $baseUrl variable should be /yii2-app-advanced/frontend/web and /yii2-app-advanced/backend/web respectively.
The server version: Apache/2.4.53. Sorry for the late answer.