Commit 6e8b2614 authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Fix htaccess generation

parent ab08b715
......@@ -26,6 +26,7 @@ namespace SGalinski\SgRoutes\Service;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Controller\ErrorPageController;
use TYPO3\CMS\Core\Core\Bootstrap;
......@@ -454,9 +455,24 @@ class RoutingService {
}
if (!$route['source_url_case_sensitive']) {
$directive = 'RedirectMatch';
$route['source_url'] = '(?i)' . \addslashes($route['source_url']);
}
if (
\is_numeric($route['destination_url']) ||
\substr($route['destination_url'], 0, 5) === 't3://'
) {
/**
* @var $routingService RoutingService
*/
$routingService = GeneralUtility::makeInstance(self::class);
$tsfe = $routingService->getTypoScriptFrontendController();
$route['destination_url'] = $tsfe->cObj->getTypoLink_URL($route['destination_url']);
}
if ($route['destination_url'] !== '') {
// only add the htaccess rule if there is a destination, because otherwise it will be 404 anyway
$htaccessEntries .= $directive . ' ' . $route['redirect_code'] . ' '
. $route['source_url'] . ' ' . $route['destination_url'] . LF;
}
$htaccessEntries .= $directive . ' ' . $route['redirect_code'] . ' ' . ($route['source_url_case_sensitive'] ? '' : '(?i)') . $route['source_url'] . ' '
. $route['destination_url'] . LF;
}
}
......
......@@ -96,7 +96,7 @@ return [
'type' => 'check',
'default' => '1'
],
'displayCond' => 'FIELD:use_regular_expression:=:REQ'
'displayCond' => 'FIELD:use_regular_expression:!=:1'
],
'destination_url' => [
'exclude' => 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment