Options -Indexes 
ErrorDocument 404 /404.php

<IfModule mod_alias.c>
  RedirectMatch 301 ^/ritual\.ru(?:/(.*))?$ https://ritual.ru/$1
</IfModule>

#Redirect /kolumbarii/ /poleznaya-informatsiya/kolumbarii/



<IfModule mod_php7.c>
  php_flag session.use_trans_sid off
  #php_value display_errors 1
  #php_value mbstring.internal_encoding UTF-8
  php_flag allow_url_fopen On
</IfModule>

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    # www. -> .

    Redirect 301 "/ritual.ru/about/" "/about/"
    # /ritual.ru/... -> /... на основном домене
    RewriteCond %{HTTP_HOST} ^(?:www\.)?ritual\.ru(?::\d+)?$ [NC]
    RewriteCond %{REQUEST_URI} ^/ritual\.ru(?:/(.*))?$ [NC]
    RewriteRule ^ https://ritual.ru/%1 [R=301,L,NE]

    RewriteCond %{REQUEST_URI} ^/ritualnie-uslugi/elitnye_vip_pohorony$ [NC]
    RewriteRule ^ /ritualnie-uslugi/elitnye_vip_pohorony/ [R=301,L]

    RewriteCond %{HTTP_HOST} (.*)
    RewriteRule ^tseny/kalkulyator/?$ https://%1/tseny/ [R=301,L]

    RewriteCond %{HTTP_HOST} ^www.kazan.ritual.ru$ [NC]
    RewriteRule ^(.*)$ https://kazan.ritual.ru/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^www.yar.ritual.ru$ [NC]
    RewriteRule ^(.*)$ https://yar.ritual.ru/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^www.perm.ritual.ru$ [NC]
    RewriteRule ^(.*)$ https://perm.ritual.ru/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www.krd.ritual.ru$ [NC]
    RewriteRule ^(.*)$ https://krd.ritual.ru/$1 [R=301,L]
    # www. -> .
    RewriteCond %{HTTP_HOST} ^www.ritual.ru$ [NC]
    RewriteRule ^(.*)$ https://ritual.ru/$1 [R=301,L]

    #####
    # Удаляем index.php из адреса
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    # Только для GET-запросов (чтобы стандартные формы работали)
    RewriteCond %{REQUEST_METHOD} =GET
    # Не применяем к админке
    RewriteCond %{REQUEST_URI} !/bitrix/admin/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) https://%{HTTP_HOST}/$1$2 [R=301,NE,L]
    #####
    # Удаляем index.html из адреса
    RewriteCond %{THE_REQUEST} ^GET.*index\.html [NC]
    # Только для GET-запросов (чтобы стандартные формы работали)
    RewriteCond %{REQUEST_METHOD} =GET
    # Не применяем к админке
    RewriteCond %{REQUEST_URI} !/bitrix/admin/.* [NC]
    RewriteRule (.*?)index\.html/*(.*) https://%{HTTP_HOST}/$1$2 [R=301,NE,L]
    #####

    #not slash redirect
    RewriteCond %{REQUEST_URI} ^(.*/[^/\.]+)$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [R=301,L]

    #remove double/more slashes in url
    RewriteCond %{REQUEST_URI} ^(.*[^/])/{2,}(.*)$
    RewriteRule . https://%{HTTP_HOST}%1/%2 [R=301,L]
    RewriteCond %{THE_REQUEST} \s/{2,}(.*)\s
    RewriteRule .* https://%{HTTP_HOST}/%1 [R=301,L]

    # redirect to https
    RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

    # ????
    RewriteCond %{THE_REQUEST} /(.*)index.php.*$
    RewriteCond %{THE_REQUEST} !bitrix/admin/
    RewriteRule .* https://%{HTTP_HOST}/%1 [R=301,L]

    Rewriterule ^robots\.txt$ /robots.php [L]
    #Rewriterule ^sitemap\.xml$ /sitemap.php [L]
    
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
  RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/jpeg "access plus 365 day"
  ExpiresByType image/gif "access plus 365 day"
  ExpiresByType image/png "access plus 365 day"
  ExpiresByType text/css "access plus 365 day"
  ExpiresByType application/javascript "access plus 365 day"  
  ExpiresByType application/json "access plus 365 day"  
  ExpiresByType image/svg+xml "access plus 365 day" 
</IfModule>

<Files "*.gitignore">
  deny from all
</Files>

# 2026-10-14: закрыт публичный доступ к .git
RedirectMatch 404 /\.git
