Created
May 23, 2016 11:13
-
-
Save ptrnov/43cc39426cda1bc6c4c203753ce8a143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [1]=== .htaccess ===> public_html ==== | |
| #Options +FollowSymlinks | |
| RewriteEngine On | |
| # deal with admin first | |
| #RewriteCond %{REQUEST_URI} ^/(admin) | |
| #RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L] | |
| #RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L] | |
| #RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/ | |
| #RewriteCond %{REQUEST_URI} ^/(admin) | |
| #RewriteRule ^.*$ backend/web/index.php [L] | |
| RewriteCond %{REQUEST_URI} ^/(assets|css) | |
| RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L] | |
| RewriteRule ^css/(.*)$ frontend/web/css/$1 [L] | |
| #RewriteCond %{REQUEST_URI} !^(frontend|backend)/web/(assets|css)/ | |
| RewriteCond %{REQUEST_URI} !^advanced/(frontend)/web/(assets|css)/ | |
| RewriteCond %{REQUEST_URI} !index.php | |
| RewriteCond %{REQUEST_FILENAME} !-f [OR] | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^.*$frontend/web/index.php [NC,L] | |
| RewriteCond %{REQUEST_FILENAME} -s [OR] | |
| RewriteCond %{REQUEST_FILENAME} -l [OR] | |
| RewriteCond %{REQUEST_FILENAME} -d | |
| #RewriteRule ^.*$ - [NC,L] | |
| #RewriteCond %{REQUEST_URI} ^/$ | |
| RewriteRule ^.*$ frontend/web/index.php [NC,L] | |
| [2]=== common/components ===> create class Request | |
| <?php | |
| namespace common\components; | |
| class Request extends \yii\web\Request { | |
| public $web; | |
| public $adminUrl; | |
| public function getBaseUrl(){ | |
| return str_replace($this->web, "", parent::getBaseUrl()) . $this->adminUrl; | |
| } | |
| /* | |
| If you don't have this function, the admin site will 404 if you leave off | |
| the trailing slash. | |
| E.g.: | |
| Wouldn't work: | |
| site.com/admin | |
| Would work: | |
| site.com/admin/ | |
| Using this function, both will work. | |
| */ | |
| public function resolvePathInfo(){ | |
| if($this->getUrl() === $this->adminUrl){ | |
| return ""; | |
| }else{ | |
| return parent::resolvePathInfo(); | |
| } | |
| } | |
| [3]=== Declaration componen ===> common/config/main.php | |
| <?php | |
| return [ | |
| 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', | |
| 'components' => [ | |
| 'cache' => [ | |
| 'class' => 'yii\caching\FileCache', | |
| ], | |
| 'request'=>[ | |
| 'class' => 'common\components\Request', | |
| 'web'=> '/frontend/web' | |
| ], | |
| ], | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My question is if I keep .htaccess file out of the project folder (on htdocs / on public_html), how can i access other project without .htaccess file on them. Whenever i want to access other project, it show me "Object Not found". If i delete the .htaccess file from htdocs / public_html it works fine. But condition is I need .htaccess file on the htdocs / public_html and also i need others project without .htdocs on them.