This allows you to handle authentication, logging or whatever else you please in your backend and then have NGINX handle serving the contents from redirected location to the end user, thus freeing up the backend to handle other requests. This feature is commonly known as X-Sendfile.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
// Для элемента
array(
"CONDITION" => "#^/podobrat-dver/([a-z0-9\-]+)/([^/\?]*)(.*)$#",
"RULE" => "SECION_CODE=\$1&ELEMENT_CODE=\$2&$3",
"PATH" => "/podobrat-dver/detail.php",
)
// Для раздела
array(
"CONDITION" => "#^/podobrat-dver/([a-z0-9\-]+)/(.*)$#",
"RULE" => "SECION_CODE=$1&$2",
"PATH" => "/podobrat-dver/section.php",
)
<?$APPLICATION->IncludeComponent(
"bitrix:catalog.element",
"detail",
array(
.....
"IBLOCK_ID" => "30",
"ELEMENT_ID" => "",
"ELEMENT_CODE" => $_REQUEST["ELEMENT_CODE"],
"SECTION_ID" => "",
"SECTION_CODE" => $_REQUEST["SECION_CODE"],
"SECTION_URL" => "",
"DETAIL_URL" => "/podobrat-dver/#ELEMENT_CODE#/",
"SECTION_ID_VARIABLE" => "ELEMENT_CODE",
"SECTION_CODE_PATH" => ""
.....
),
false
);?>
<?$APPLICATION->IncludeComponent(
"bitrix:catalog.section",
"catalog_list",
array(
....
"DETAIL_URL" => "/podobrat-dver/#ELEMENT_CODE#/",
"SECTION_CODE" => $_REQUEST["SECTION_CODE"],
"SECTION_ID" => "",
"SECTION_URL" => "",
"SHOW_ALL_WO_SECTION" => "Y",
....
),
false
);?>
//region Try to extract user action data
// We have to extract them before call of CGridOptions::GetFilter() or the custom filter will be corrupted.
$actionData = array(
'METHOD' => $_SERVER['REQUEST_METHOD'],
'ACTIVE' => false
);
if(check_bitrix_sessid())
{
$postAction = 'action_button_'.$arResult['GRID_ID'];
$getAction = 'action_'.$arResult['GRID_ID'];
//We need to check grid 'controls'
$controls = isset($_POST['controls']) && is_array($_POST['controls']) ? $_POST['controls'] : array();
if ($actionData['METHOD'] == 'POST' && (isset($controls[$postAction]) || isset($_POST[$postAction])))
{
CUtil::JSPostUnescape();
$actionData['ACTIVE'] = true;
if(isset($controls[$postAction]))
{
$actionData['NAME'] = $controls[$postAction];
}
else
{
$actionData['NAME'] = $_POST[$postAction];
unset($_POST[$postAction], $_REQUEST[$postAction]);
}
...
...
...
$actionData['AJAX_CALL'] = $arResult['IS_AJAX_CALL'];
}
}
//endregion
// POST & GET actions processing -->
if($actionData['ACTIVE'])
{
if ($actionData['METHOD'] == 'POST')
{
if($actionData['NAME'] == 'delete')
{
...
elseif($actionData['NAME'] == 'assign_to')
{
if(isset($actionData['ASSIGNED_BY_ID']))
{
$arIDs = array();
if ($actionData['ALL_ROWS'])
{
$arActionFilter = $arFilter;
$arActionFilter['CHECK_PERMISSIONS'] = 'N'; // Ignore 'WRITE' permission - we will check it before update.
$dbRes = CCrmDeal::GetListEx(array(), $arActionFilter, false, false, array('ID'));
while($arDeal = $dbRes->Fetch())
{
$arIDs[] = $arDeal['ID'];
}
}
elseif (isset($actionData['ID']) && is_array($actionData['ID']))
{
$arIDs = $actionData['ID'];
}
foreach($arIDs as $ID)
{
if (!CCrmDeal::CheckUpdatePermission($ID, $userPermissions))
{
continue;
}
$DB->StartTransaction();
$arUpdateData = array(
'ASSIGNED_BY_ID' => $actionData['ASSIGNED_BY_ID']
);
if($CCrmDeal->Update($ID, $arUpdateData, true, true, array('DISABLE_USER_FIELD_CHECK' => true)))
{
$DB->Commit();
$arErrors = array();
CCrmBizProcHelper::AutoStartWorkflows(
CCrmOwnerType::Deal,
$ID,
CCrmBizProcEventType::Edit,
$arErrors
);
}
else
{
$DB->Rollback();
}
}
}
}
...
}
}
// <-- POST & GET actions processing
use Bitrix\TestPartner\TestPartnerModule\TestPartnerModuleListTable;
use TestPartner\TestPartnerModule\TestPartnerModuleListTable;
Можно ли это сделать встроенными средствами битрикса?
Может есть готовые дополнения?
/* @var string Регулярное выражение для проверки */
$regex = '#^http(s?):\/\/domain\.com\/?(index\.html|test\.html)?$#';
/* @var array Проверяемые варианты */
$arVariant = [
'http://domain.com',
'https://domain.com',
'http://domain.com/',
'https://domain.com/',
'http://domain.com/index.html',
'https://domain.com/index.html',
'http://domain.com/test.html',
'https://domain.com/test.html',
'http://domain.com/blabla.html',
'https://domain.com/blabla.html',
'https://domain.com/test.html?page=1',
];
foreach( $arVariant as $variant )
{
if ( preg_match($regex, $variant) )
{
echo "Ссылка '{$variant}' не прошла валидацию".PHP_EOL;
}
}
Ссылка 'http://domain.com' не прошла валидацию
Ссылка 'https://domain.com' не прошла валидацию
Ссылка 'http://domain.com/' не прошла валидацию
Ссылка 'https://domain.com/' не прошла валидацию
Ссылка 'http://domain.com/index.html' не прошла валидацию
Ссылка 'https://domain.com/index.html' не прошла валидацию
Ссылка 'http://domain.com/test.html' не прошла валидацию
Ссылка 'https://domain.com/test.html' не прошла валидацию