Skip to content

Instantly share code, notes, and snippets.

@bisubus
Last active November 4, 2016 06:40
Show Gist options
  • Save bisubus/2479a5579c5f1f27c546 to your computer and use it in GitHub Desktop.
Save bisubus/2479a5579c5f1f27c546 to your computer and use it in GitHub Desktop.
Yii 2 Advanced Application Template on virtual hosting
Options -Indexes
<IfModule !mod_rewrite.c>
Deny from all
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# no recursion
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/rearend(/.*|)$
# no recursion if '/backend/' is used as backend alias
RewriteCond %{REQUEST_URI} !^/backend/web(/.*|)$
RewriteRule ^rearend(/.*|)$ backend/web$1 [L]
RewriteCond %{REQUEST_URI} !^/backend/web(/.*|)$
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
// ...
'bootstrap' => [
function () {
$path = '/rearend/';
$filename = basename(Yii::$app->getRequest()->getScriptFile());
Yii::$app->getRequest()->setScriptUrl($path . $filename);
Yii::$app->getRequest()->setBaseUrl(rtrim($path, '/'));
},
'log',
// ...
],
// ...
// ...
'bootstrap' => [
function () {
$path = '/';
$filename = basename(Yii::$app->getRequest()->getScriptFile());
Yii::$app->getRequest()->setScriptUrl($path . $filename);
Yii::$app->getRequest()->setBaseUrl(rtrim($path, '/'));
},
'log',
// ...
],
// ...
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^. index.php
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment