W
W
WebLedNik2020-08-28 18:57:14
1C-Bitrix
WebLedNik, 2020-08-28 18:57:14

How can I set up the CNC in the bitrix.news component?

Good evening or afternoon)

Problem: with the CNC turned on, the text of the news is not displayed on the detailed view page of the news. Goes to the main page, although it writes the address of a non-main page in the URL.
To display news, I use the bitrix.news complex component.

The list of news is displayed at: /article/index.php Infoblock

settings:
5f492836225e0788083139.png

CNC component settings:
5f492856e04d4237496109.png

urlrewrite.php in the root of the news site there is the following entry:

5 => 
  array (
    'CONDITION' => '#^/article/#',
    'RULE' => '',
    'ID' => 'bitrix:news',
    'PATH' => '/article/index.php',
    'SORT' => 100,
  ),


With the CNC turned off, everything works in the component.
Help to properly configure the CNC of the bitrix.news component.

.htaccess in site root:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2020-08-28
@WebLedNik

URL страницы информационного блока: /article/index.php
URL страницы раздела:	пусто
URL страницы детального просмотра:	/article/#ELEMENT_CODE#/

Make sure that the symbolic code is specified for the elements, otherwise replace with ID
In the component settings:
Управление адресами страниц: /article/
Страница детального просмотра:	#ELEMENT_CODE#/
Включить поддержку ЧПУ: Да
Остальное пусто

After saving in urlrewrite.php it will be something like this:
13 => 
  array (
    'CONDITION' => '#^/article/#',
    'RULE' => '',
    'ID' => 'bitrix:news',
    'PATH' => '/article/index.php',
    'SORT' => 100,
  ),

At the request of the author of the topic, I will transfer my answer from the comment here:
htaccess should be something like this if Apache.
Options -Indexes 
ErrorDocument 404 /404.php


  php_flag session.use_trans_sid off
  #php_flag default_charset UTF-8
  #php_value display_errors 1


<IfModule mod_php7.c>
  php_flag session.use_trans_sid off
  #php_flag default_charset UTF-8
  #php_value display_errors 1
</IfModule>

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  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}]
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/jpeg "access plus 3 day"
  ExpiresByType image/gif "access plus 3 day"
  ExpiresByType image/png "access plus 3 day"
  ExpiresByType text/css "access plus 3 day"
  ExpiresByType application/javascript "access plus 3 day"  
</IfModule>

R
Roman Morozov, 2021-10-11
@Q_BASIC

here is a complete instruction for setting up the CNC in Bitrix
If in the section with a complex component Bitrix tells you that there is no page, you may have the following error:
The CNC is configured to work with character codes, but they are not filled in
Different CNC settings in the parameters of the component and infoblock.
Record not created in urlrewrite.php
Broke .htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question