[TYPO3-english] TYPO3 in subdirectory with silent domain redirect

Jan Bednarik info at bednarik.org
Fri Oct 12 09:32:27 CEST 2012


Hey,

I have a TYPO3 installed in a subdirectory "old" and I want it to run on 
a domain www.example.com.

In order to redirect all requests to the subdirectory, I placed into the 
main directory's .htaccess this:

RewriteCond %{HTTP_HOST} ^(www\.)?wellness-spa\.cz$
RewriteRule ^(?!old/)(.*)$ /old/$1 [L]

Since I want nice URLs, I have the default .htaccess in old directory. 
So far, it is fine.

However, when I go to www.example.com/typo3, I'm redirected to 
www.example.com/old/typo3, still works and is fine.

But the problem is that the View module in TYPO3 then displays 
www.example.com/old/nice/url, which is obviously not recognized.

I tried all sort of things with .htaccess, but without luck. The last 
resort was hacking index.php and adding:

if (substr($_SERVER['REQUEST_URI'],0,4) == '/old') {
   header('Location: 
http://www.example.com'.substr($_SERVER['REQUEST_URI'],4,strlen($_SERVER['REQUEST_URI'])-4),301);
   exit;
}

Since it's a terrible hack, I'm asking here, whether someone managed to 
make this scenario working.

Thanks

Jan


More information about the TYPO3-english mailing list