Redirect 301 /old-folder http://www.website.de/index.php?id=38
Redirect 301 /old-folder http://www.website.de/new-folder/
Redirect 301 /en/site.html http://www.website.de/index.php?id=115
Redirect 301 /en/site.html http://www.website.de/en/index.php?id=115
This question has been answered by rainbowtiger. See the first response.
# MODX supports Friendly URLs via this .htaccess file. You must serve web # pages via Apache with mod_rewrite to use this functionality, and you must # change the file name from ht.access to .htaccess. # # Make sure RewriteBase points to the directory where you installed MODX. # E.g., "/modx" if your installation is in a "modx" subdirectory. # # You may choose to make your URLs non-case-sensitive by adding a NC directive # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC] RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.website\.de [NC] RewriteRule (.*) http://www.website.de/$1 [R=301,L] # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent # https://www.domain.com when your cert only allows https://secure.domain.com #RewriteCond %{SERVER_PORT} !^443 #RewriteRule (.*) https://example-domain-please-change.com/$1 [R=301,L] RewriteRule joomla http://www.website.de? [L,R=301] RewriteRule ck-editor http://www.website.de? [L,R=301] RewriteRule fckeditor http://www.website.de? [L,R=301] RewriteRule fck http://www.website.de? [L,R=301] RewriteRule Fck http://www.website.de? [L,R=301] RewriteRule FCK http://www.website.de? [L,R=301] ... # redirect all requests to /de/favicon.ico and /nl/favicon.ico # to /favicon.ico RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en)/favicon.ico$ favicon.ico [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en)/layout.css$ layout.css [L,QSA] # redirect all requests to /de/assets* and /nl/assets* to /assets* RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en)/assets(.*)$ assets$2 [L,QSA] # redirect all requests to /de/assets* and /nl/assets* to /assets* RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en)/pdf(.*)$ pdf$2 [L,QSA] # redirect all requests to /de/assets* and /nl/assets* to /assets* RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en)/pressemitteilungen(.*)$ pressemitteilungen$2 [L,QSA] # redirect all requests to /de/assets* and /nl/assets* to /assets* RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en)/images(.*)$ images$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 ^(de|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA] Redirect 301 /stiftung/site.html http://www.website.de/index.php?id=8 Redirect 301 /service.html http://www.website.de/index.php?id=18 Redirect 301 /en/service.html http://www.website.de/index.php?id=193 # Make sure .htc files are served with the proper MIME type, which is critical # for XP SP2. Un-comment if your host allows htaccess MIME type overrides. #AddType text/x-component .htc # If your server is not already configured as such, the following directive # should be uncommented in order to set PHP's register_globals option to OFF. # This closes a major security hole that is abused by most XSS (cross-site # scripting) attacks. For more information: http://php.net/register_globals # # To verify that this option has been set to OFF, open the Manager and choose # Reports -> System Info and then click the phpinfo() link. Do a Find on Page # for "register_globals". The Local Value should be OFF. If the Master Value # is OFF then you do not need this directive here. # # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS : # # Your server does not allow PHP directives to be set via .htaccess. In that # case you must make this change in your php.ini file instead. If you are # using a commercial web host, contact the administrators for assistance in # doing this. Not all servers allow local php.ini files, and they should # include all PHP configurations (not just this one), or you will effectively # reset everything to PHP defaults. Consult www.php.net for more detailed # information about setting PHP directives. #php_flag register_globals Off # For servers that support output compression, you should pick up a bit of # speed by un-commenting the following lines. #php_flag zlib.output_compression On #php_value zlib.output_compression_level 5 # The following directives stop screen flicker in IE on CSS rollovers. If # needed, un-comment the following rules. When they're in place, you may have # to do a force-refresh in order to see changes in your designs. #ExpiresActive On #ExpiresByType image/gif A2592000 #ExpiresByType image/jpeg A2592000 #ExpiresByType image/png A2592000 #BrowserMatch "MSIE" brokenvary=1 #BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1 #BrowserMatch "Opera" !brokenvary #SetEnvIf brokenvary 1 force-no-vary
Redirect 301 /en/service.html http://www.website.de/index.php?id=193
http://www.website.de/index.php?q=en/service.html
<?php /* LangRouter * ========== * * This plugin is meant to be used with Babel extra for MODX Revolution. It * takes care of switching contexts, which hold translations, depending on URL * requested by client. LangRouter works with so called subfolder based setup, * in which many languages are served under a single domain but are * differentiated by a virtual subfolder indicating the language, eg. * mydomain.com/pl/. * * The routing work as follows: * - if URI contains cultureKey, which is defined in Babel configuration, then * the matching context is served * - if URI doesn't contain cultureKey (or one not defined in Babel * configuration) AND at least one of the client's accepted languages is * defined in Babel configuration, then the matching context is served * - otherwise the default context is served * * LangRouter works out-of-the-box and doesn't require any changes to URL * rewrite rules in the webserver configuration. All routing is handled * internally by MODX. This greatly simplifies the setup and provides * portability. LangRouter was tested with Apache and Lighttpd. * * Setup: * 1. Prepare your contexts as you normally would for Babel. * 2. For each context set `base_url` to `/`. * 3. For each context set `site_url` to * `{server_protocol}://{http_host}{base_url}{cultureKey}/` * 4. Add new system setting `babel.contextDefault` and set it to the default * context, which should be served when no language is specified in * request, eg. `pl`. * 5. Include static files from the assets folder with * `[[++assets_url]]path/to/static_file`. * 6. In template header use `<base href="[[++site_url]]" />`. * 7. Use default URL generation scheme in MODX (ie. relative). * * This code is shared AS IS. Use at your own risk. */ if($modx->context->get('key') != "mgr") { /* * Debugs request handling */ function logRequest($message = 'Request') { global $modx; $modx->log(modX::LOG_LEVEL_ERROR, $message . ':' . "\n REQUEST_URI: " . $_SERVER['REQUEST_URI'] . "\n REDIRECT_URI: " . $_SERVER['REDIRECT_URI'] . "\n QUERY_STRING: " . $_SERVER['QUERY_STRING'] . "\n q: " . $_REQUEST['q'] . "\n Context: " . $modx->context->get('key') . "\n Site start: " . $modx->context->getOption('site_start') ); } /* * Dumps variables to MODX log */ function dump($var) { ob_start(); var_dump($var); return ob_get_clean(); } /* * Detects client language preferences and returns associative array sorted * by importance (q factor) */ function clientLangDetect() { $langs = array(); if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { # break up string into pieces (languages and q factors) preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); if (count($lang_parse[1])) { # create a list like "en" => 0.8 $langs = array_combine($lang_parse[1], $lang_parse[4]); # set default to 1 for any without q factor foreach ($langs as $lang => $val) { if ($val === '') $langs[$lang] = 1; } # sort list based on value arsort($langs, SORT_NUMERIC); return $langs; } } } #logRequest('Unhandled request'); # Get contexts and their cultureKeys $babelContexts = explode(',', $modx->getOption('babel.contextKeys')); $languages = array(); foreach ($babelContexts as $context) { $ctx = $modx->getContext($context); $languages[$ctx->config['cultureKey']] = trim($context); } #$modx->log(modX::LOG_LEVEL_ERROR, dump($languages)); # Determine language from request $reqCultureKeyIdx = strpos($_REQUEST['q'], '/'); $reqCultureKey = substr($_REQUEST['q'], 0, $reqCultureKeyIdx); # Serve the proper context and language if(array_key_exists( strtolower($reqCultureKey), array_change_key_case($languages))) { $modx->switchContext($reqCultureKey); # Remove cultureKey from request $_REQUEST['q'] = substr($_REQUEST['q'], $reqCultureKeyIdx+1); #logRequest('Culture key found in URI'); } else { $clientCultureKey = array_flip( array_intersect_key(clientLangDetect(), $languages)); if($clientCultureKey) { $contextDefault = current($clientCultureKey); } else { $contextDefault = trim($modx->getOption('babel.contextDefault')); } if($reqCultureKey == $defaultLang) $reqCultureKey = 'web'; #$modx->log(modX::LOG_LEVEL_ERROR, dump($contextDefault)); if($reqCultureKey == $modx->getOption('cultureKey')) $reqCultureKey = $modx->getOption('babel.contextDefault'); $modx->switchContext($contextDefault); #logRequest('Culture key not found in URI'); $modx->sendRedirect($modx->context->getOption('site_url')); } # Serve site_start when no resource is requested if(empty($_REQUEST['q'])) { #$modx->log(modX::LOG_LEVEL_ERROR, 'Query is empty'); $modx->sendForward($modx->context->getOption('site_start')); } } if($contextDefault == $modx->getOption('cultureKey')) $contextDefault = $modx->getOption('babel.contextDefault');
Redirect 301 /old-folder http://www.website.de/new-folder/