[TYPO3-english] Multi-language rewriting/caching issues

Thomas Skierlo pubtsk1 at pix-pro.eu
Mon Mar 12 20:55:39 CET 2012


Hello,

I am trying to refactor a configuration of a TYPO3 4.5.4 website 
(multi-language, single-tree, realurl, tt_news, TV) before updating it 
to a more recent version. I want to use Apache vhost configuration 
instead of .htaccess for performance reasons. I know that tt_news 3.1 
will put me in another hell of multilanguage problems, but my very first 
problem is a differnt one: Duplicate content.

Imagine a website with 3 languages (default = english = 0, german = 1, 
dutch = 2). I have a domain record set for www.example.eu 
<http://www.example.eu/>, which is my main domain for all 3 languages.

Non-www traffic is redirected to www by means of Apache vhost permanent 
redirect (outside TYPO3 rewriting). A shortcut on the root page leads to 
the start page. To get my language switch working with tt_news, I had to 
use L-Vars not only for the additional languages, but for of all of them 
(0/1/2). My language url-scheme looks like:

www.example.eu/en/ <http://www.example.eu/en/> instead of 
www.example.eu/ <http://www.example.eu/> (for the default language)

www.example.eu/de/ <http://www.example.eu/de/>

www.example.eu/nl/ <http://www.example.eu/nl/>

To get this language behaviour I use the following part of realurl config:

'preVars' => array(

'0' => array(

  'GETvar' => 'no_cache',

'valueMap' => array(

'nc' => 1,

),

'noMatch' => 'bypass',

),

'1' => array(

'GETvar' => 'L',

'valueMap' => array(

'en' => '0',

'de' => '1',

'nl' => '2',

),

'valueDefault' => 'en',

),

),

With this settings I get a working configuration, even with multilingual 
tt_news 3.01 (after some heavy patching of the page browser), but a look 
at the caching reveals my problem:

After accessing just the domain I get cache entries for the following:

www.example.eu | id=9    path: en/home/

www.example.eu <http://www.example.eu/> | id=9&L=0    path: en/home/

www.example.eu <http://www.example.eu/> | id=9&L=1    path: de/home/

www.example.eu <http://www.example.eu/> | id=9&L=2    path: nl/home/

Notice the first one. That's the one which is responsible for the 
duplicate content. To get rid of the first entry and redundant caching I 
think I must find a solution to redirect all traffic without any L-Var 
to the default (L=0)

www.example.eu <http://www.example.eu/>?id=9 ==> www.example.eu 
<http://www.example.eu/>?id=9&L=0

Currently I use the following rewrite configuration, which is otherwise 
working properly:


RewriteEngine On

# non-www redirect handled outside this scenario

# TYPO3 rewriting

# Rule for versioned static files, configured through:

# - $TYPO3_CONF_VARS['BE']['versionNumberInFilename']

# - $TYPO3_CONF_VARS['FE']['versionNumberInFilename']

# IMPORTANT: This rule has to be the very first RewriteCond in order to 
work!

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

# Stop rewrite processing for certain files and directories :

RewriteRule 
^/(typo3/|t3lib/|tslib/|fileadmin/|typo3conf/|typo3temp/|uploads/|showpic\.php|favicon\.ico)/ 
- [L]

# Redirect http://example.com/typo3 to 
http://example.com/typo3/index.php (all Backend accesses)

RewriteRule ^/typo3$ /typo3/index.php [L]

# If the file/symlink/directory does not exist => Redirect to index.php.

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* /index.php [L]


Probably the only thing that's missing is a rule to redirect
www.example.eu <http://www.example.eu/>?id=9 ==> www.example.eu 
<http://www.example.eu/>?id=9&L=0

or, in terms of realurl:

www.example.eu/ <http://www.example.eu/> ==> www.example.eu/en/

I'm struggling all day to find a configuration which is working with or 
without realurl enabled, but I'm too far away from being a rewriting 
expert. I've found a couple of solutions to the same problem in older 
threads, something like:

RewriteRule !^/(en|de|nl)/ http://%{HTTP_HOST}/en%{REQUEST_URI} [R=301,L]

or

RewriteRule ^(en/)?(.*)$ http://www.example.eu/$1 [L,R]

but I don't like the idea of mixing semantic and non-semantic parameters 
in one configuration. This definitely is neither a problem of TYPO3 
caching nor of realurl. Rewriting is hell, any help apprechiated.

TIA for any help,

Greetings from Holland

Thomas


More information about the TYPO3-english mailing list