Skip to content

Instantly share code, notes, and snippets.

@x404
Forked from bartholomej/.htaccess
Last active November 7, 2017 20:11
Show Gist options
  • Save x404/e8a88a9c378ad9ac7481829470d07303 to your computer and use it in GitHub Desktop.
Save x404/e8a88a9c378ad9ac7481829470d07303 to your computer and use it in GitHub Desktop.
MODx htaccess for Babel
# MODX htaccess for BABEL (idealab settings)
RewriteEngine On
RewriteBase /
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
# redirect all requests to /de/favicon.ico and /nl/favicon.ico
# to /favicon.ico
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(web|en)/favicon.ico$ favicon.ico [L,QSA]
# redirect all requests to /de/assets* and /nl/assets* to /assets*
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(web|en)/assets(.*)$ assets$2 [L,QSA]
# redirect all other requests to /de/* and /nl/*
# to index.php and set the cultureKey parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(web|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
php_flag zlib.output_compression On
php_value zlib.output_compression_level 5
<?php
if($modx->context->get('key') != "mgr"){
/* grab the current langauge from the cultureKey request var */
switch ($_REQUEST['cultureKey']) {
case 'en':
/* switch the context */
$modx->switchContext('en');
break;
default:
/* Set the default context here */
$modx->switchContext('web');
break;
}
/* unset GET var to avoid
* appending cultureKey=xy to URLs by other components */
unset($_GET['cultureKey']);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment