<Directory>
доступна только в server config, virtual host.<Directory not allowed here
AllowOverride None
на AllowOverride All
sudo a2enmod rewrite
sudo service apache2 restart
RewriteCond %{QUERY_STRING} (?:^|&)page=(\d+)
RewriteRule ^(.*)$ /$1page/%1/? [R=301,L]
DirectorySlash off
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule (.*) /$1.html [L]
сайт.ру/q?example=1 было сайт.ру/q/example/1
RewriteCond %{QUERY_STRING} (?:^|&)(example)=(1)(?:$|&)
RewriteRule ^q$ https://site.ru/q/%1/%2? [R=301,L]
Modifiers
Particular items can be restricted to print only for responses with specific HTTP status codes by placing a comma-separated list of status codes immediately following the "%". The status code list may be preceded by a "!" to indicate negation.
%!
перечислить через запятую коды ответов которые нужно исключить.CustomLog "logs/access_log" combined "expr=!%{REQUEST_STATUS} -in {'200', '301','302'}"
RewriteCond %{QUERY_STRING} (^|&)PAGEN_1=1($|&)
RewriteCond %{QUERY_STRING} (^|&)SIZEN_1=50($|&)
RewriteRule ^(.*)$ /$1? [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} SemrushBot-SA|rogerbot|megaindex\.com
RewriteRule ^ - [F]
<VirtualHost>
# Переезд на https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Убираем www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://example.com/page/ [R=301,L]
RewriteCond %{THE_REQUEST} " /wp/ "
RewriteRule ^ https://example.com/page/ [R=301,L]
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?>www\.|)(.+) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{SERVER_PORT}%{HTTP_HOST} !^443(?!www\.) [NC]
RewriteCond %{HTTP_HOST} ^(?>www\.|)(.+) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{SERVER_PORT}%{HTTP_HOST} ^(?|443www\.(.+)|80(?>www\.|)(.+)) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
server {
listen 443 ssl;
server_name site.io;
access_log off;
ssl_certificate "/var/node/********.crt";
ssl_certificate_key "/var/node/********.key";
root /var/www/service/public_html;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/api/v2/(.+) {
try_files $uri /api/v2/index.php?q=$1&$args;
}
}
RewriteCond %{HTTP_HOST} ^old-site\.ru$ [NC]
RewriteRule ^(.*)$ http://www.new-site.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(?:www\.|)(.+)\.old-site\.ru$ [NC]
RewriteRule ^(.*)$ http://%1.new-site.ru/$1 [R=301,L]
#
old-site.ru -> www.new-site.ru
www.old-site.ru -> www.new-site.ru
one.old-site.ru -> one.new-site.ru
www.one.old-site.ru -> one.new-site.ru
two.old-site.ru -> two.new-site.ru
www.two.old-site.ru -> two.new-site.ru
RedirectMatch 301 ^/product/(.+(guide|bulbs))$ /$1
RewriteEngine on
RewriteRule ^product/(.+(guide|bulbs))$ /$1 [R=301,L]
^([^/]*)/([^/]*)/([^/]*)$
^(\d+)/(content)/(.+)$