Created
January 23, 2018 10:06
-
-
Save ptflp/8706c0fbd697e93e486b2df024f2ea47 to your computer and use it in GitHub Desktop.
Yii2 advanced .htaccess configuration
This file contains 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
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 |
This file contains 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
# 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 |
This file contains 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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok