Search code examples
typo3subdomaincdntypo3-8.x

How to set up own CDN with subdomain on Typo3 v8?


As Content Replacer (ja_replacer) is not supported by Typo3 v8 is there any other way to replace url strings in Typo3 v8 and setup own CDN Service?

To make it more clear, in Typo3 v4.5-6.1 it would look like that:

config.tx_ja_replacer {
  search {
    1="typo3temp/
    2="fileadmin/
    3="typo3conf/
  }
  replace {
    1="https://cdn.domain.de/typo3temp/
    2="https://cdn.domain.de/fileadmin/
    3="https://cdn.domain.de/typo3conf/
  }
}

But this extension is not supported anymore.

Thanks in advance!

---- EDIT 1 ----

If someone is still interested in 'ja_replacer', this is a Typo3 v7 & v8 Fork: ja_replace for Typo3 v7-8

With this I managed it to work but encountered CORS problems even if fonts where set to wildcard origins

---- EDIT 2 ----

Testes this (by Mario Naether) but this also did not worked (even with page.stdWrap.replacement)

page.stdWrap.replacement {
  10.search = #"fileadmin\/#
  10.replace = "https://cdn.domain.de/fileadmin/
  10.useRegExp = 1
  11.search = #"typo3temp\/#
  11.replace = "https://cdn.domain.de/typo3temp/
  11.useRegExp = 1
  12.search = #"typo3conf\/#
  12.replace = "https://cdn.domain.de/typo3conf/
  12.useRegExp = 1
}

---- EDIT 3 ----

Finaly I found a solution which satisfies me. (if I'm logged in) I posted it here as answer.

This is actually working.. but not if I'm not logged in... So now I have to manage it to work even if I load the Website without beeing logged in.


Solution

  • Soooo after some days of research I found a good solution which is working with Typo3 v7.6.0 - v8.99.99

    Install ja-replacer (by PHORAX)

    and add this Code to your TypoScript

    #CDN über Sub-Domain 'CDN.DOMAIN.de'
    config.tx_ja_replacer{
      search {
        10="/typo3temp/
        11="typo3temp/
        12="/fileadmin/
        13="fileadmin/
        14="/typo3conf/
        15="typo3conf/
      }
    
      replace {
        10="https://CDN.DOMAIN.de/typo3temp/
        11="https://CDN.DOMAIN.de/typo3temp/
        12="https://CDN.DOMAIN.de/fileadmin/
        13="https://CDN.DOMAIN.de/fileadmin/
        14="https://CDN.DOMAIN.de/typo3conf/
        15="https://CDN.DOMAIN.de/typo3conf/
      }
    }
    
    #Domain-replace Setup für CDN
    [globalString = ENV:HTTP_HOST = WWW.DOMAIN.de]
      page.config.baseURL = https://WWW.DOMAIN.de/
      config.tx_ja_replacer.replace < tx_ja_replacer
    [global]
    

    1.) Now replace every "cdn.domain.de" with your own CDN-Subdomain or CDN-Domain

    2.) replace every "www.domain.de" to your Domain.

    2b) if necessary change the value of "page.config.baseURL" to just http and not https if your not using https

    ---- EDIT 1 ----

    Somehow this is just working fine as long as I'm logged in. When I load my Typo3 Website without beeing logged in it does not replace anything.