Commit 9da32470ed1c19432c22e875a78b6789683a49a1
1 parent
e2525f1d
routs
Showing
5 changed files
with
118 additions
and
29 deletions
Show diff stats
.htaccess
| 1 | - AddDefaultCharset utf-8 | ||
| 2 | - | ||
| 3 | - Options -Indexes +FollowSymlinks -MultiViews | ||
| 4 | - DirectoryIndex index.php | ||
| 5 | - | ||
| 6 | - AddHandler server-parsed .html | ||
| 7 | - AddOutputFilter INCLUDES .html | 1 | +<IfModule mod_rewrite.c> |
| 8 | 2 | ||
| 9 | - SetEnv TZ Europe/Kiev | 3 | + Options +FollowSymlinks |
| 10 | 4 | ||
| 11 | RewriteEngine On | 5 | RewriteEngine On |
| 12 | 6 | ||
| 7 | +</IfModule> | ||
| 8 | + | ||
| 13 | <IfModule mod_rewrite.c> | 9 | <IfModule mod_rewrite.c> |
| 14 | 10 | ||
| 15 | - RewriteEngine On | 11 | + RewriteBase / |
| 12 | + # deal with admin first | ||
| 13 | + RewriteRule ^storage/(.*)?$ /storage/$1 [L,PT] | ||
| 14 | + | ||
| 15 | + RewriteCond %{REQUEST_URI} ^/(admin) | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L] | ||
| 20 | + | ||
| 21 | + RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L] | ||
| 22 | + | ||
| 23 | + RewriteRule ^admin/js/(.*)$ backend/web/js/$1 [L] | ||
| 24 | + | ||
| 25 | + RewriteRule ^admin/images/(.*)$ backend/web/images/$1 [L] | ||
| 26 | + | ||
| 27 | + RewriteRule ^admin/fonts/(.*)$ backend/web/fonts/$1 [L] | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css|js|images|fonts)/ | ||
| 34 | + | ||
| 35 | + RewriteCond %{REQUEST_URI} ^/(admin) | ||
| 36 | + | ||
| 37 | + RewriteRule ^.*$ backend/web/index.php [L] | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + RewriteCond %{REQUEST_URI} ^/(assets|css) | ||
| 42 | + | ||
| 43 | + RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L] | ||
| 44 | + | ||
| 45 | + RewriteRule ^css/(.*)$ frontend/web/css/$1 [L] | ||
| 46 | + | ||
| 47 | + RewriteRule ^js/(.*)$ frontend/web/js/$1 [L] | ||
| 48 | + | ||
| 49 | + RewriteRule ^images/(.*)$ frontend/web/images/$1 [L] | ||
| 50 | + | ||
| 51 | + RewriteRule ^fonts/(.*)$ frontend/web/fonts/$1 [L] | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js|images|fonts)/ | ||
| 55 | + | ||
| 56 | + RewriteCond %{REQUEST_URI} !index.php | ||
| 57 | + | ||
| 58 | + RewriteCond %{REQUEST_FILENAME} !-f [OR] | ||
| 16 | 59 | ||
| 17 | - # the main rewrite rule for the frontend application | ||
| 18 | - RewriteCond %{REQUEST_URI} !^/(backend/web|admin) | ||
| 19 | - RewriteRule !^frontend/web /frontend/web%{REQUEST_URI} [L] | ||
| 20 | - | ||
| 21 | - RewriteCond %{REQUEST_URI} ^/frontend/web | ||
| 22 | - RewriteCond %{REQUEST_FILENAME} !-f | ||
| 23 | - RewriteCond %{REQUEST_FILENAME} !-d | ||
| 24 | - RewriteRule . /frontend/web/index.php [L] | ||
| 25 | - | ||
| 26 | - RewriteCond %{REQUEST_URI} ^/backend/web | ||
| 27 | - RewriteCond %{REQUEST_FILENAME} !-f | ||
| 28 | RewriteCond %{REQUEST_FILENAME} !-d | 60 | RewriteCond %{REQUEST_FILENAME} !-d |
| 29 | - RewriteRule . /backend/web/index.php [L] | ||
| 30 | 61 | ||
| 31 | - RewriteCond %{REQUEST_URI} \.(htaccess|htpasswd|svn|git) | ||
| 32 | - RewriteRule \.(htaccess|htpasswd|svn|git) - [F] | ||
| 33 | - | 62 | + RewriteRule ^.*$ frontend/web/index.php |
| 63 | + | ||
| 64 | +</IfModule> | ||
| 65 | + | ||
| 66 | +#для возможности загрузки файлов парсера | ||
| 67 | +<IfModule mod_php5.c> | ||
| 68 | + php_value upload_max_filesize 20M | ||
| 69 | + php_value post_max_size 30M | ||
| 34 | </IfModule> | 70 | </IfModule> |
| 35 | \ No newline at end of file | 71 | \ No newline at end of file |
backend/config/main.php
| @@ -40,6 +40,15 @@ return [ | @@ -40,6 +40,15 @@ return [ | ||
| 40 | 'errorHandler' => [ | 40 | 'errorHandler' => [ |
| 41 | 'errorAction' => 'site/error', | 41 | 'errorAction' => 'site/error', |
| 42 | ], | 42 | ], |
| 43 | + 'request'=>[ | ||
| 44 | + | ||
| 45 | + 'class' => 'common\components\Request', | ||
| 46 | + | ||
| 47 | + 'web'=> '/backend/web', | ||
| 48 | + | ||
| 49 | + 'adminUrl' => '/admin' | ||
| 50 | + | ||
| 51 | + ], | ||
| 43 | ], | 52 | ], |
| 44 | 'params' => $params, | 53 | 'params' => $params, |
| 45 | ]; | 54 | ]; |
| 1 | +<?php | ||
| 2 | +namespace common\components; | ||
| 3 | + | ||
| 4 | +class Request extends \yii\web\Request | ||
| 5 | + | ||
| 6 | +{ | ||
| 7 | + | ||
| 8 | + public $web; | ||
| 9 | + | ||
| 10 | + public $adminUrl; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + public function getBaseUrl() | ||
| 15 | + | ||
| 16 | + { | ||
| 17 | + | ||
| 18 | + return str_replace($this->web, "", parent::getBaseUrl()) . $this->adminUrl; | ||
| 19 | + | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + public function resolvePathInfo() | ||
| 25 | + | ||
| 26 | + { | ||
| 27 | + | ||
| 28 | + if ($this->getUrl() === $this->adminUrl) { | ||
| 29 | + | ||
| 30 | + return ""; | ||
| 31 | + | ||
| 32 | + } else { | ||
| 33 | + | ||
| 34 | + return parent::resolvePathInfo(); | ||
| 35 | + | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | +} | ||
| 0 | \ No newline at end of file | 41 | \ No newline at end of file |
common/config/main.php
| @@ -6,12 +6,10 @@ return [ | @@ -6,12 +6,10 @@ return [ | ||
| 6 | 'class' => 'yii\caching\FileCache', | 6 | 'class' => 'yii\caching\FileCache', |
| 7 | ], | 7 | ], |
| 8 | 'urlManager' => [ | 8 | 'urlManager' => [ |
| 9 | - 'enablePrettyUrl' => false, | 9 | + 'enablePrettyUrl' => true, |
| 10 | 'showScriptName' => false, | 10 | 'showScriptName' => false, |
| 11 | 'class'=> 'common\components\LangUrlManager', | 11 | 'class'=> 'common\components\LangUrlManager', |
| 12 | 'rules'=>[ | 12 | 'rules'=>[ |
| 13 | - '/' => 'site/index', | ||
| 14 | - '<controller:\w+>/<action:\w+>/*'=>'<controller>/<action>', | ||
| 15 | ] | 13 | ] |
| 16 | ], | 14 | ], |
| 17 | 'request' => [ | 15 | 'request' => [ |
frontend/config/main.php
| @@ -17,6 +17,13 @@ return [ | @@ -17,6 +17,13 @@ return [ | ||
| 17 | 'identityClass' => 'common\models\User', | 17 | 'identityClass' => 'common\models\User', |
| 18 | 'enableAutoLogin' => true, | 18 | 'enableAutoLogin' => true, |
| 19 | ], | 19 | ], |
| 20 | + 'request'=>[ | ||
| 21 | + | ||
| 22 | + 'class' => 'common\components\Request', | ||
| 23 | + | ||
| 24 | + 'web'=> '/frontend/web' | ||
| 25 | + | ||
| 26 | + ], | ||
| 20 | 'log' => [ | 27 | 'log' => [ |
| 21 | 'traceLevel' => YII_DEBUG ? 3 : 0, | 28 | 'traceLevel' => YII_DEBUG ? 3 : 0, |
| 22 | 'targets' => [ | 29 | 'targets' => [ |
| @@ -34,8 +41,7 @@ return [ | @@ -34,8 +41,7 @@ return [ | ||
| 34 | 'enablePrettyUrl' => true, | 41 | 'enablePrettyUrl' => true, |
| 35 | 'showScriptName' => false, | 42 | 'showScriptName' => false, |
| 36 | 'rules' => [ | 43 | 'rules' => [ |
| 37 | - '' => 'site/index', | ||
| 38 | - '<controller>/<action>' => '<controller>/<action>', | 44 | + |
| 39 | ] | 45 | ] |
| 40 | ], | 46 | ], |
| 41 | ], | 47 | ], |