[TYPO3] Coolori - redirect fails with http://www.example.org/www.example.com@

Andreas Burg typo3 at andreasburg.de
Thu Jul 31 00:32:40 CEST 2008


Steffen Gebert schrieb:
> Hi Jan,
> 
> Sorry for starting yet another bug report on the list (should I write it to
> forge instead?). It's just because I can't localize the real problem.
> 
> I've got a problem with redirecting to a new created domain. All the old
> links from a whole branch don't work.
> 
> Situation as follows:
> URL is www.example.org/sompath/; since some days they've got their own
> domain www.example.com
> so www.example.org/sompath/* should be redirected to www.example.com/*
> 
> Link_Translate::cool2params finds nothing in link_cache, so searches in
> link_oldlinks
> 
> SELECT link_cache.url AS oldlink FROM link_oldlinks  LEFT JOIN link_cache ON
> link_oldlinks.link_id=link_cache.id WHERE
> link_oldlinks.url='www.example.org at somepath/'
> this returns oldlink = www.example.com@ (so far, so good)
> 
> This result is processed in
> Link_Func::redirect(Link_Func::prepareforRedirect($row['oldlink'].(empty($te
> mpuri[1])?'':'?'.$tempuri[1]),$lConf));
> 
> Link_Func::prepareforRedirect($path = 'www.example.com@', $lConf)
> returns 'www.example.com@'
> is this still GOOD?
> 
> LinkFunc::redirect($path = 'www.example.com@')
> if (!preg_match('~^http://~',$path))
> matches of course NOT, so 
> 'http://'.$_SERVER['HTTP_HOST'].'/' is prepended to $path
> 
> header('Location: '.$path);
> with $path = http://www.example.org/www.example.com@
> 
> So far, so BAD.
> 
> I wonder how ever it worked in the past. I think
> Link_Func::prepareforRedirect does sth. wrong. There I don't understand
> if (....&&
> substr($path,0,strlen($lConf->cache->prefix))==$lConf->cache->prefix) {
>   $path = 'http://...';
> }
> I think we should add http:// also for $path not starting with
> $lConf->cache->prefix but anything else containing an @ (which might lead to
> other problems...)
> What should $lConf->cache->prefix be? Is www.example.org@ right, while
> calling www.example.org/somepath/ or should it be www.example.com@ instead?
> Then the if-clause should be okay (but anything else wrong...)
> 
> Also link_cache and link_oldlinks looks good. Hope you can see, where
> http:// should be added before calling redirect (and I think this should be
> done in prepareforRedirect)
> 
> Thanks for your support!
> 
> Steffen
> 

Hello Steffen,

sorry, that my answer ins't that complicated as your question ;-)

But I've solved such a problem with a simple .htaccess

---
RewriteEngine On
# outcomment folloinw 2 lines if you work on your server at home
# RewriteCond %{HTTP_HOST}  !^127.0.0.1
# RewriteCond %{HTTP_HOST}  !^localhost [NC]

RewriteCond %{HTTP_HOST}  !^example\.com [NC]
RewriteCond %{HTTP_HOST}  !^$
RewriteRule ^(.*)         http://example.com/$1 [L]
---

I don't know if it's perfect, perhaps you can do it better and tell me(301 redirect?), but it works 
great for me. All SE-listed URLs get the new TLD. f.e.

http://example.org/products.html =>
http://example.com/products.html

tell me

Andreas


More information about the TYPO3-english mailing list