Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ilopx/yii2-basic-htaccess

File htaccess for yii2 basic
https://github.com/ilopx/yii2-basic-htaccess

htaccess php yii yii2-basic

Last synced: 4 months ago
JSON representation

File htaccess for yii2 basic

Awesome Lists containing this project

README

        

#Yii2 basic htaccess

![Demo](https://github.com/ilopX/yii2-basic-htaccess/blob/master/example.png)

## Video Demo
[![Video Demo](http://img.youtube.com/vi/0sxqNaznhlc/0.jpg)](http://www.youtube.com/watch?v=0sxqNaznhlc)

## a. Automatic setting [index.php](https://cdn.rawgit.com/ilopX/yii2-basic-htaccess/master/index.php)
This method created .htaccess files automatically and clear self.

+ Download file [index.php](https://cdn.rawgit.com/ilopX/yii2-basic-htaccess/master/index.php) or composer require ilopx/yii2-basic-htaccess
+ Put to root yii2 application
+ Start http://{your_yii2_webapp}
+ Follow [step 3 in Manual setting](#3-step)

## b. Manual setting
### 1. step
#### create file {root}/.htaccess:
```

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^(.*)$ web/$1 [L]

RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php

```

### 2. step
#### create file {root}/web/.htaccess:
```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
```
### 3. step
#### update file {root}/config/web.php:
```php
'request' => [
'baseUrl' => '',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
''=>'site/',
],
],
```