Skip to content

Apache mod_rewrite

Все запросы на https

# All to https
RewriteEngine On 
RewriteCond %{HTTPS}  !=on 
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 

Все запросы на index.php

#
RewriteBase /
RewriteRule ^index\.php$ - [L]
# исключения для существующих файлов и каталогов
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 
RewriteRule ^ /index.php [L]

no-www to www

# Redirect to www
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Block GET requests to URL

RewriteCond %{REQUEST_METHOD} ^GET [NC]
RewriteCond %{REQUEST_URI} ^/search
RewriteRule .* - [F,L]