@brar

Почему битра отвечает «200 OK» на несуществующие в url-е section_code?

Дефолтная установка и битры и nginx.
Пример.
УРЛ с реально существующим товаром:
mytestsite.ru/catalog/realniy_podcatalog/realniy_tovar/


Так вот, значение realniy_podcatalog можно менять как угодно в адресной строке браузера (или утилиты curl). И в любом случае попадаем на страницу с товаром.
То есть, например так:
mytestsite.ru/catalog/ne_suschestvuyushiy_podcatalog334fsdgsgf/realniy_tovar/


Если обращаться к адресу только подкаталога, без товара, то всё, как надо - отдается ошибка 404.
mytestsite.ru/catalog/ne_suschestvuyushiy_podcatalog334fsdgsgf/


В битркисе в настройках каталога в качестве детальной информации проставлено #SECTION_CODE#/#ELEMENT_CODE#/
А если задать #SECTION_CODE_PATH#/#ELEMENT_CODE#/, то всё опять-таки хороошо - выдает 404.

На всякий случай конфиг nginx:

server {
    listen       80;
    server_name  mytestsite.ru;
    return       301 https://$host$request_uri;
}
server {
        listen 443 ssl;
        ssi on;
        server_name mytestsite.ru;
        charset off;
        index index.php;
	fastcgi_read_timeout 600;
        root /var/www/mytestsite;
        set $php_sock unix:/run/php/php7.3-fpm.sock;
	

        location / {
                try_files       $uri $uri/ @bitrix;
        }

        location ~* /upload/.*\.(php|phtml|pl|asp|aspx|cgi|dll|exe|shtm|shtml|fcg|fcgi|fpl|asmx|pht|py|psp|rb|var)$ {
                types {
                        text/plain text/plain php phtml pl asp aspx cgi dll exe ico shtm shtml fcg fcgi fpl asmx pht py psp rb var;
                }
        }

        location ~ \.php$ {
                try_files       $uri @bitrix;
                fastcgi_pass    $php_sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f wm@test.ru";
                include fastcgi_params;
        }
        location @bitrix {
                fastcgi_pass    $php_sock;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f wm@test.ru";
        }
        location ~* /bitrix/admin.+\.php$ {
                try_files       $uri @bitrixadm;
                fastcgi_pass    $php_sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f wm@test.ru";
                include fastcgi_params;
        }
        location @bitrixadm{
                fastcgi_pass    $php_sock;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/404.php;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f wm@test.ru";
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        #
        # block this locations for any installation
        #

        # ht(passwd|access)
        location ~* /\.ht  { deny all; }

        # repositories
        location ~* /\.(svn|hg|git) { deny all; }

        # bitrix internal locations
        location ~* ^/bitrix/(modules|local_cache|stack_cache|managed_cache|php_interface) {
          deny all;
        }

        # upload files
        location ~* ^/upload/1c_[^/]+/ { deny all; }

        # use the file system to access files outside the site (cache)
        location ~* /\.\./ { deny all; }
        location ~* ^/bitrix/html_pages/\.config\.php { deny all; }
        location ~* ^/bitrix/html_pages/\.enabled { deny all; }

        # Intenal locations
        location ^~ /upload/support/not_image   { internal; }

        # Cache location: composite and general site
        location ~* @.*\.html$ {
          internal;
          # disable browser cache, php manage file
          expires -1y;
          add_header X-Bitrix-Composite "Nginx (file)";
        }

        # Player options, disable no-sniff
        location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
          add_header Access-Control-Allow-Origin *;
        }

        # Accept access for merged css and js
        location ~* ^/bitrix/cache/(css/.+\.css|js/.+\.js)$ {
          expires 30d;
          error_page 404 /404.html;
        }

        # Disable access for other assets in cache location
        location ~* ^/bitrix/cache              { deny all; }

        # Use nginx to return static content from s3 cloud storage
        # /upload/bx_cloud_upload/<schema>.<backet_name>.<s3_point>.amazonaws.com/<path/to/file>
        # Static content
        location ~* ^/(upload|bitrix/images|bitrix/tmp) {
          expires 30d;
        }

        location  ~* \.(css|js|gif|png|jpg|jpeg|ico|ogg|ttf|woff|eot|otf)$ {
          error_page 404 /404.html;
          expires 30d;
        }

        location = /404.html {
                access_log off ;
        }

}

  • Вопрос задан
  • 259 просмотров
Решения вопроса 1
@tgarl
Потому что по умолчанию проверяется не весь путь, а только та часть которая отвечает за вывод или раздела или товара.
В последних версиях настроек компонента есть галочка проверять весь путь(не помню как точно она обзывается) включите ее, тогда будет проверяться именно весь путь. Если такого нет, то придется вам самому делать такую проверку. Просто ЧПУ это правило подмены гет запроса вида 'RULE' => 'SECTION_CODE=$1&ELEMENT_CODE=$2',
когда загружается раздел проверяется только SECTION_CODE=$1, когда товар только ELEMENT_CODE=$2 - одним словом это древняя тема которая тянется с первых версий существования битрикса.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы