W: H: YOffset??
Related Media
Categories   /  Tags

.htaccess & route enhancers in TYPO3 from v 11

Script snippets for individual redirects or to avoid BE login errors in Typo3 versions from V 11. Furthermore, extended file handling, nice urls due mod_rewrite for tx_news and various regular expressions.

Redirects

.htaccess file in website root.

Redirection from http to https taking into account the subdomain (www.)

 

#.htaccess
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ www.domain.com/$1 [L,R=301]
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ www.domain.com/$1 [R=301,L]
</IfModule>
#The redirect now works as follows:
#http://www.domain.de will be redirected to www.domain.de.
#http://domain.de will be redirected to -https://www.domain.de.
#https://domain.de will be redirected to -https://www.domain.de.

 

 

Route enhancers focusing tx_news in /config/sites/xyz/config.yaml

Example for two language system and nice urls in tx_news ( list, detail, category, tags ) and ke_search.
TYPO3 11 & TYPO3 12 tested.

 


base: /
languages:
  -
    title: English
    enabled: true
    languageId: 0
    base: /
    locale: en_US.UTF-8
    navigationTitle: English
    flag: us
    hreflang: ''
    websiteTitle: ''
  -
    title: German
    enabled: true
    locale: de_DE
    hreflang: de-DE
    base: /de/
    websiteTitle: 'your-domain.com'
    navigationTitle: German
    fallbackType: fallback
    fallbacks: '0'
    flag: de
    languageId: 1
rootPageId: 1
routeEnhancers:
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: /
        _controller: 'News::list'
      -
        routePath: '/page-{page}'
        _controller: 'News::list'
        _arguments:
          page: currentPage
      -
        routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      -
        routePath: '/{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
      -
        routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
    defaultController: 'News::list'
    defaults:
      page: '0'
    aspects:
      news-title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      category-name:
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
  PageTypeSuffix:
    type: PageType
    map:
      feed.xml: 9818
      calendar.ical: 9819
websiteTitle: your-domain.com