Classes/Service/HtaccessService.php
public function write(string $originalFileName, int $lifetime, string $originalContent)
    {
        $configuration = GeneralUtility::makeInstance(ConfigurationService::class);
        $tagService = GeneralUtility::makeInstance(TagService::class);

        $fileName = PathUtility::pathinfo($originalFileName, PATHINFO_DIRNAME) . '/.htaccess';
        $accessTimeout = (int)$configuration->get('htaccessTimeout');
        $lifetime = $accessTimeout ? $accessTimeout : $lifetime;

        $tags = $tagService->isEnable() ? $tagService->getTags() : [];

        $variables = [
            'mode' => $accessTimeout ? 'A' : 'M',
            'lifetime' => $lifetime,
            'expires' => (new DateTimeService())->getCurrentTime() + $lifetime,
            'typo3headers' => GeneralUtility::makeInstance(TypoScriptFrontendService::class)->getAdditionalHeaders(),
            'sendCacheControlHeader' => $configuration->isBool('sendCacheControlHeader'),
            'sendCacheControlHeaderRedirectAfterCacheTimeout' => $configuration->isBool('sendCacheControlHeaderRedirectAfterCacheTimeout'),
            'sendTypo3Headers' => $configuration->isBool('sendTypo3Headers'),
            'tags' => \implode(',', $tags),
            'tagHeaderName' => $tagService->getHeaderName(),
            'sendStaticFileCacheHeader' => $configuration->isBool('sendStaticFileCacheHeader'),
            'httpPushHeaders' => GeneralUtility::makeInstance(HttpPushService::class)->getHttpPushHeaders($originalContent),
        ];

        $this->renderTemplateToFile($this->getTemplateName(), $variables, $fileName);
    }
public function write(string $originalFileName, int $lifetime, string $originalContent)
    {
        $configuration = GeneralUtility::makeInstance(ConfigurationService::class);
        $tagService = GeneralUtility::makeInstance(TagService::class);

        $fileName = PathUtility::pathinfo($originalFileName, PATHINFO_DIRNAME) . '/.htaccess';
        $accessTimeout = (int)$configuration->get('htaccessTimeout');
        $lifetime = $accessTimeout ? $accessTimeout : $lifetime;

        $tags = $tagService->isEnable() ? $tagService->getTags() : [];

        $variables = [
            'mode' => $accessTimeout ? 'A' : 'M',
            'lifetime' => $lifetime,
            'expires' => (new DateTimeService())->getCurrentTime() + $lifetime,
            'typo3headers' => GeneralUtility::makeInstance(TypoScriptFrontendService::class)->getAdditionalHeaders(),
            'sendCacheControlHeader' => $configuration->isBool('sendCacheControlHeader'),
            'sendCacheControlHeaderRedirectAfterCacheTimeout' => $configuration->isBool('sendCacheControlHeaderRedirectAfterCacheTimeout'),
            'sendTypo3Headers' => $configuration->isBool('sendTypo3Headers'),
            'tags' => \implode(',', $tags),
            'tagHeaderName' => $tagService->getHeaderName(),
            'sendStaticFileCacheHeader' => $configuration->isBool('sendStaticFileCacheHeader'),
            'httpPushHeaders' => GeneralUtility::makeInstance(HttpPushService::class)->getHttpPushHeaders($originalContent),
        ];

        $this->renderTemplateToFile($this->getTemplateName(), $variables, $fileName);
    }
public function write ( string $ originalFileName , int $ lifetime , string $ originalContent ) { $ configuration = GeneralUtility :: makeInstance ( ConfigurationService :: class ) ; $ tagService = GeneralUtility :: makeInstance ( TagService :: class ) ; $ fileName = PathUtility :: pathinfo ( $ originalFileName , PATHINFO_DIRNAME ) . '/.htaccess' ; $ accessTimeout = ( int ) $ configuration -> get ( 'htaccessTimeout' ) ; $ lifetime = $ accessTimeout ? $ accessTimeout : $ lifetime ; $ tags = $ tagService -> isEnable ( ) ? $ tagService -> getTags ( ) : [ ] ; $ variables = [ 'mode' => $ accessTimeout ? 'A' : 'M' , 'lifetime' => $ lifetime , 'expires' => ( new DateTimeService ( ) ) -> getCurrentTime ( ) + $ lifetime , 'typo3headers' => GeneralUtility :: makeInstance ( TypoScriptFrontendService :: class ) -> getAdditionalHeaders ( ) , 'sendCacheControlHeader' => $ configuration -> isBool ( 'sendCacheControlHeader' ) , 'sendCacheControlHeaderRedirectAfterCacheTimeout' => $ configuration -> isBool ( 'sendCacheControlHeaderRedirectAfterCacheTimeout' ) , 'sendTypo3Headers' => $ configuration -> isBool ( 'sendTypo3Headers' ) , 'tags' => \ implode ( ',' , $ tags ) , 'tagHeaderName' => $ tagService -> getHeaderName ( ) , 'sendStaticFileCacheHeader' => $ configuration -> isBool ( 'sendStaticFileCacheHeader' ) , 'httpPushHeaders' => GeneralUtility :: makeInstance ( HttpPushService :: class ) -> getHttpPushHeaders ( $ originalContent ) , ] ; $ this -> renderTemplateToFile ( $ this -> getTemplateName ( ) , $ variables , $ fileName ) ; }
Write htaccess file.

@param string $originalFileName
@param int    $lifetime
@param string $originalContent
Write htaccess file .