location @имя { ... }
с нужными fastcgi_param или sub_filter.*.txt
обрабатывает сам, то правилами htaccess тут не решить.*.txt
, а когда файла с таким именем не нашлось, то проксирует запрос на Apache.RewriteRule ^robots\.txt$ robots_blabla.txt [L]
listen 80;
server_name www.example.com;
listen *:80;
server_name example.com;
listen *:443 ssl;
server_name example.com;
https://www.site.ru
server {
listen 443 ssl;
server_name www.site.ru;
ssl_certificate ... ;
ssl_certificate_key ... ;
return 301 https://site.ru$request_uri;
}
<VirtualHost>
сайта где нужно закрыть доступ ботам.IncludeOptional sites-enabled/*.conf
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require expr %{HTTP_USER_AGENT} !~ /SemrushBot-SA|rogerbot|megaindex\.com/
</Directory>
Redirect 301 /o-kompanii/novosti/motorezina-na-lyuboy-vkus/ /company/news/motorezina_na_lyuboy_vkus/
Redirect 301 /o-kompanii/novosti/podbor-zapchastey-po-artikulu/ /company/news/podbor_zapchastey_po_artikulu/
Redirect 301 /o-kompanii/novosti/bystraya-dostavka/ /company/news/bystraya_dostavka/
Redirect 301 /o-kompanii/novosti/poshiv-ekipirovki-tschul-po-vashim-parametram-pod-zakaz/ /company/news/poshiv_ekipirovki_tschul_po_vashim_parametram_pod_zakaz/
Redirect 301 /o-kompanii/novosti/aktsiya-na-produktsiyu-motul/ /company/news/aktsiya_na_produktsiyu_motul/
Redirect 301 /o-kompanii/novosti/postuplenie-shlemov-hjc/ /company/news/postuplenie_shlemov_hjc/
Redirect 301 /o-kompanii/novosti/ /company/news/
Redirect 301 /o-kompanii/otzyvy-pokupateley.php /company/reviews/
Redirect 301 /o-kompanii/ /company/
Redirect 301 /dostavka-oplata/dostavka-po-rossii.php /help/delivery/
Redirect 301 /dostavka-oplata/oplata.php /help/payment/
Redirect 301 /dostavka-oplata/ /help/
Redirect 301 /pokupatelyam/obmen-i-vozvrat.php /help/warranty/
Redirect 301 /pokupatelyam/tablici-razmerov.php /help/tablitsa-razmerov/
Redirect 301 /pokupatelyam/zaschita-prav-polzovateley.php /include/licenses_detail.php
Redirect 301 /pokupatelyam/ /help/warranty/
Redirect 301 /kontakty/ /contacts/
Redirect 301 /cart/ /basket/
Redirect 301 /account/spisok-sravneniya/ /catalog/compare.php
Redirect 301 /account/ /personal/
Redirect 301 /brandy/ /info/brands/
Redirect 301 /o-kompanii/ /company/
server {
listen 80;
server_name mydomain.ru;
return 301 http://www.mydomain.ru$request_uri;
}
server {
listen 80;
server_name www.mydomain.ru;
root /path/to/site;
index index.php index.html;
rewrite "^/404/{0,1}$" /index.php?module=sitemap break;
rewrite "^/adm/{0,1}$" /admin.php break;
rewrite "^/adm/([a-zA-Z0-9_-]+)/{0,1}$" /admin.php?module=$1 break;
rewrite "^/adm/([a-zA-Z0-9_-]+)/([0-9]+)/{0,1}$" /admin.php?module=$1&page=$2 break;
rewrite "^/adm/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/{0,1}$" /admin.php?module=$1&p1=$2 break;
rewrite "^/adm/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/{0,1}$" /admin.php?module=$1&p1=$2&p2=$3 break;
if (!-e $request_filename){
rewrite "^/([a-zA-Z0-9_-]+).html/{0,1}$" /index.php?module=static&p1=$1 break;
}
if (!-e $request_filename){
rewrite "^/([a-zA-Z0-9_-]+)/{0,1}$" /index.php?module=$1 break;
}
rewrite "^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/{0,1}$" /index.php?module=$1&p1=$2 break;
rewrite "^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/{0,1}$" /index.php?module=$1&p1=$2&p2=$3 break;
rewrite "^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/{0,1}$" /index.php?module=$1&p1=$2&p2=$3&p3=$4 break;
location ~ \.php$ {
fastcgi_pass ... ;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(catalog)/(perchatki/.*)$ /$1/ekipirovka/$2 [R=301,L]
# ASPRO_ROBOTS Serve robots.txt with robots.php only if the latter exists
RewriteCond %{REQUEST_FILENAME} robots.txt
RewriteCond %{DOCUMENT_ROOT}/robots.php -f
RewriteRule ^(.*)$ /robots.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}]
RewriteRule ^(catalog)/(perchatki/.*)$ /$1/ekipirovka/$2 [R=301,L]
# ASPRO_ROBOTS Serve robots.txt with robots.php only if the latter exists
RewriteCond %{REQUEST_FILENAME} robots.txt
RewriteCond %{DOCUMENT_ROOT}/robots.php -f
RewriteRule ^(.*)$ /robots.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]
https://yandex.ru/blog/platon/pereezd-sayta-posle-...