We have hybrid Magento + Typo3 system and want - for Magento - have URLs like that:
de/produkte/
en/products/
fr/produits/
ru/produkty/
cn/zhìpǐn/
it/prodotti/
es/productos/
Typo3 would overlay the same structure (de/presse
+ en/press
and so on)
What I did is to set the web/(un)secure/base_url
to a different URL per store view.
#de
n98-magerun.phar config:set web/unsecure/base_url --scope=stores --scope-id=1 "$BASE"de/produkte/
n98-magerun.phar config:set web/secure/base_url --scope=stores --scope-id=1 "$SECURE_BASE"de/produkte/
#en
n98-magerun.phar config:set web/unsecure/base_url --scope=stores --scope-id=2 "$BASE"en/products/
n98-magerun.phar config:set web/secure/base_url --scope=stores --scope-id=2 "$SECURE_BASE"en/products/
Also I defined in the web-root .htaccess
# URL Rewriting to Magento
RewriteRule ^de/produkte/ mage/index.php [L,env=MAGE_RUN_CODE:de]
RewriteRule ^en/products/ mage/index.php [L,env=MAGE_RUN_CODE:en]
RewriteRule ^fr/produits/ mage/index.php [L,env=MAGE_RUN_CODE:fr]
RewriteRule ^ru/produkty/ mage/index.php [L,env=MAGE_RUN_CODE:ru]
RewriteRule ^cn/zhìpǐn/ mage/index.php [L,env=MAGE_RUN_CODE:cn]
RewriteRule ^it/prodotti/ mage/index.php [L,env=MAGE_RUN_CODE:it]
RewriteRule ^es/productos/ mage/index.php [L,env=MAGE_RUN_CODE:es]
But now in Magento, I only get a page not found from Magento.
As a workaround I rewrote the function \Mage_Core_Controller_Request_Http::getBaseUrl`
public function getBaseUrl()
{
$url = parent::getBaseUrl();
$url = str_replace('\\', '/', $url);
// Workaround Patch
$parts = explode('/', $this->getRequestUri());
if ($parts[1] == $_SERVER['MAGE_RUN_CODE']) {
$url = implode('/', array_slice($parts, 0, 3)) . $url;
}
return $url;
}
which removes the specific part from the URL.
While this is working, I am wondering if there is an easier solution? Shouldn't Magento automatically strip away the current base_url
?
/mage/
- and for the link URL/de/produkte/
, but if I open the page, it redirects me to/mage/
- what was the idea behind your comment?