[TYPO3-ttnews] Force www vs non-www to avoid duplicate content on Google and RealUrl

Oliver Rowlands oliver at liquidlight.co.uk
Fri Jun 12 17:25:09 CEST 2009


Hi Trine,

The reason it will not work is because mod_rewrite will try to rewrite 
internally after executing the non-www to www redirect resulting in the 
rewrite being captured by the TYPO3 'catch all' rewrite rule.

In order to prevent this you simply need to specify the 'L' flag in the 
non-www to www rewrite rule which stands for 'last', preventing any 
further internal rewrites from occuring.

The following should work:

### Enable mod_rewrite ###
RewriteEngine On

### Restrict domain access ###
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301,L]

### TYPO3 ###
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

HTH,

Oliver

Trine Buhl wrote:
> Hi,
> 
> I am looking a solution to force www vs non-www to avoid duplicate 
> content on Google which will work with RealUrl.
> 
> I have found this snippet, but it dosn't work with my existing 
> rewrite-setup in .htaccess.
> 
> 
> RewriteEngine on
> RewriteCond %{HTTP_HOST} !^www.your_domain.com$
> RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
> 
> My existing .htaccess:
> 
>         RewriteEngine On
>         RewriteRule ^typo3$ - [L]
>         RewriteRule ^typo3/.*$ - [L]
>         RewriteCond %{REQUEST_FILENAME} !-f
>         RewriteCond %{REQUEST_FILENAME} !-d
>         RewriteCond %{REQUEST_FILENAME} !-l
>         RewriteRule .* index.php
> 
> Is it possible to integrate the RealUrl rewrite of filenames with the 
> rewrite of http_host?
> 
> Is there only a manually solution to go for?
> 
> Regards,
> 
> Trine


-- 
Oliver Rowlands
:: Liquid Light ::

E - oliver at liquidlight.co.uk
W - http://www.liquidlight.co.uk

T - 00 44 (0)845 6 58 88 35
F - 00 44 (0)845 6 58 44 35


More information about the TYPO3-project-tt-news mailing list