Skip to content

muhiddingithub/yii2-basic-htaccess

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

#Yii2 basic htaccess root/.htaccess:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
</IfModule>
 
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/.*
    #RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
    #RewriteRule ^css/(.*)$ web/css/$1 [L]
    #RewriteRule ^js/(.*)$ web/js/$1 [L]
    #RewriteRule ^images/(.*)$ web/images/$1 [L]
    RewriteRule ^(.*)$ web/$1 [L]

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

root/web/.htaccess:

# Если это папка или файл, открываем его
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# В противном случае перенаправляем на index.php
RewriteRule . index.php

root/config/web.php:

'request' => [
    'baseUrl' => '',
],
'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        '' => 'site/index',
        '<action>'=>'site/<action>',
    ],
],
'assetManager' => [
    'basePath' => '@webroot/assets',
    'baseUrl' => '@web/assets'
],

About

Файл htaccess для yii2 basic

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 70.3%
  • ApacheConf 29.7%