Skip to content

Instantly share code, notes, and snippets.

@ptflp
Created January 23, 2018 10:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ptflp/8706c0fbd697e93e486b2df024f2ea47 to your computer and use it in GitHub Desktop.
Save ptflp/8706c0fbd697e93e486b2df024f2ea47 to your computer and use it in GitHub Desktop.
Yii2 advanced .htaccess configuration
Options -Indexes
Options FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^/admin/$
RewriteRule ^(admin)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} ^.*$
RewriteRule ^(.*)$ /frontend/web/$1
# use mode rewrite for pretty URL support
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php
<IfModule mod_rewrite.c>
Options +FollowSymlinks
# Включаем mod_rewrite и перенаправляем со слэша
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
# Если это папка или файл, открываем ее/его
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# В противном случае перенаправляем на index.php
RewriteRule . index.php
</IfModule>
@samadovmirzabek
Copy link

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment