Skip to content

Commit

Permalink
Create .htaccess
Browse files Browse the repository at this point in the history
  • Loading branch information
DeFiTON authored Sep 13, 2023
1 parent 28c7554 commit bdde634
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# --- Настройка перезаписи ---
# Включаем перезапись
RewriteEngine On

# Принудительное использование домена без "www"
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# Если запрашиваемый файл или директория не существует, перенаправляем на главную страницу
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ / [L,R=301]

# --- Настройки безопасности ---
# Запрещаем доступ к .htaccess
<Files .htaccess>
Order allow,deny
Deny from all
</Files>

# --- Настройки оптимизации ---
# Включаем сжатие Gzip для текстовых файлов
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
</IfModule>

# Устанавливаем заголовки кэширования для статических ресурсов
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
</IfModule>

0 comments on commit bdde634

Please sign in to comment.