项目作者: ilopX

项目描述 :
File htaccess for yii2 basic
高级语言: PHP
项目地址: git://github.com/ilopX/yii2-basic-htaccess.git
创建时间: 2015-01-24T21:52:31Z
项目社区:https://github.com/ilopX/yii2-basic-htaccess

开源协议:

下载


Yii2 basic htaccess

Demo

Video Demo

Video Demo

a. Automatic setting index.php

This method created .htaccess files automatically and clear self.

b. Manual setting

1. step

create file {root}/.htaccess:

  1. <IfModule mod_rewrite.c>
  2. Options +FollowSymlinks
  3. RewriteEngine On
  4. </IfModule>
  5. <IfModule mod_rewrite.c>
  6. RewriteCond %{REQUEST_URI} ^/.*
  7. RewriteRule ^(.*)$ web/$1 [L]
  8. RewriteCond %{REQUEST_URI} !^/web/
  9. RewriteCond %{REQUEST_FILENAME} !-f [OR]
  10. RewriteCond %{REQUEST_FILENAME} !-d
  11. RewriteRule ^.*$ web/index.php
  12. </IfModule>

2. step

create file {root}/web/.htaccess:

  1. RewriteCond %{REQUEST_FILENAME} !-f
  2. RewriteCond %{REQUEST_FILENAME} !-d
  3. RewriteRule . index.php

3. step

update file {root}/config/web.php:

  1. 'request' => [
  2. 'baseUrl' => '',
  3. ],
  4. 'urlManager' => [
  5. 'enablePrettyUrl' => true,
  6. 'showScriptName' => false,
  7. 'rules' => [
  8. '' => 'site/index',
  9. '<action>'=>'site/<action>',
  10. ],
  11. ],