@seotuning

Блокировка через nginx страниц типа /xfsearch/sezon/page/10?

У DLE много косяков, в том числе есть бесполезные страницы типа https://anime-free.ru/xfsearch/sezon/page/10, по сути, просто дубли никому не нужные. Можно запретить индексирование в robots.txt, но хотелось бы блокировать такого рода страницы через nginx отдавая код 403, например. Как прописать такое правило правильно?
map $uri $new_urirare {
    include /etc/nginx/catstostaticrare.map;
}
server {


error_page 404 @missing;
 
 location @missing {
    if ($request_uri ~ /(xfsearch/seazon/(.*)/)page/){
      return 302 $scheme://domain.com/$1;
    }
      rewrite ^(.*)$  /404/404.html last;
    }
 location = /404/404.html {
	internal; 
	}
	proxy_intercept_errors        on;
	server_name domain.com www.domain.com;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/domain.com/*.conf;
	access_log /var/www/httpd-logs/domain.com.access.log;
	error_log /var/www/httpd-logs/domain.com.error.log notice;
	ssi on;
	set $root_path /var/www/seotuning/data/www/domain.com;
	root $root_path;
	listen ip:80;
	if ($bad_bot = 1) { return 403; }
	if ($new_urirare) {
rewrite ^ $new_urirare permanent;
}
	gzip on;
	gzip_comp_level 5;
	gzip_disable "msie6";
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
	
	
	
	
				location /uploads/posts/ {
		add_header Access-Control-Allow-Origin "*";
					set $button_redirect 0;
					set $disable_cache 1;
					if ($http_referer ~ "domain\.com$") {
        expires 30d;
        set $disable_cache 0;
    }
	if ($http_referer ~  "\.google\.|\.yahoo\.|yandex\.|\.bing\.") { set $button_redirect 1; }
	if ($http_accept ~ "^image") { set $button_redirect 0; }
	if ($http_user_agent ~* "googlebot|msnbot|baiduspider|slurp|webcrawler|teoma|photon|facebookexternalhit|facebookplatform|pinterest|feedfetcher|ggpht|photon|smush\.it|akamai|cloudfront|netdna|bitgravity|maxcdn|edgecast|limelight|tineye|developers|gstatic|googleapis|googleusercontent|ytimg") {
        set $button_redirect 0;
    }
	if ($http_referer ~* "translate\.google|microsofttranslator\.|pinterest\.|tumblr\.|facebook\.|plus\.google|twitter\.|googleapis\.|googleusercontent\.|ytimg\.|gstatic\.") {
        set $button_redirect 0;
    }
	if ($button_redirect = 1) {
        rewrite "^/uploads/posts/([0-9]+)-(.*)\.(jpg|jpeg|png|gif)$" https://domain.com/$1-.html;
    }
	 if ($disable_cache = 1) {
        expires off;
        add_header Cache-Control "no-cache, must-revalidate";
    }
  }
  
  location /rarebig/ {
  alias /disk1/filesrarefgd/;
		add_header Access-Control-Allow-Origin "*";
					set $button_redirect 0;
					set $disable_cache 1;
					if ($http_referer ~ "domain\.com$") {
        expires 30d;
		
        set $disable_cache 0;
    }
	if ($http_referer ~  "\.google\.|\.yahoo\.|yandex\.|\.bing\.") { set $button_redirect 1; }
	if ($http_accept ~ "^image") { set $button_redirect 0; }
	if ($http_user_agent ~* "googlebot|msnbot|baiduspider|slurp|webcrawler|teoma|photon|facebookexternalhit|facebookplatform|pinterest|feedfetcher|ggpht|photon|smush\.it|akamai|cloudfront|netdna|bitgravity|maxcdn|edgecast|limelight|tineye|developers|gstatic|googleapis|googleusercontent|ytimg") {
        set $button_redirect 0;
    }
	if ($http_referer ~* "translate\.google|microsofttranslator\.|pinterest\.|tumblr\.|facebook\.|plus\.google|twitter\.|googleapis\.|googleusercontent\.|ytimg\.|gstatic\.") {
        set $button_redirect 0;
    }
	if ($button_redirect = 1) {
        rewrite "^/uploads/posts/([0-9]+)-(.*)\.(jpg|jpeg|png|gif)$" https://domain.com/$1-.html;
    }
	 if ($disable_cache = 1) {
        expires off;
        add_header Cache-Control "no-cache, must-revalidate";
    }
  }
  
  
  	  		location /thumbs/ {
expires 30d;
		alias /disk1/rareth/;
		add_header Access-Control-Allow-Origin "*";					
  }
    	  		location /thumbnail/ {
expires 30d;
		alias /disk1/thhhrare/;
		add_header Access-Control-Allow-Origin "*";					
  }
	
	
location /xfsearch/seazon/page/ {
return 403;
}	 
	
	
	
	
	location / {
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @fallback;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
			expires 24d;
			try_files $uri $uri/ @fallback;
		}
		location / {
			try_files /does_not_exists @fallback;
		}
	}
	location @fallback {
		proxy_pass http://127.0.0.1:8080;
		proxy_redirect http://127.0.0.1:8080 /;
		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Forwarded-Port $server_port;
		access_log off;
	}
}
  • Вопрос задан
  • 99 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы