1. Внешний (301) редирект выполняет не Apache, а modx (судя по всему, анализирует содержимое полей глобальной переменной $_SERVER — иначе как modx узнает, что на уровне веб-сервера был изменён URI ресурса, который ему втюхали)
/** * Cleans the resource identifier from the request params. * * @param string $identifier The raw identifier. * @return string|integer The cleansed identifier. */ public function _cleanResourceIdentifier($identifier) { if (empty ($identifier)) { ... } elseif ($this->modx->getOption('friendly_urls', null, false) && $this->modx->resourceMethod == 'alias') { $containerSuffix = trim($this->modx->getOption('container_suffix', null, '')); $found = $this->modx->findResource($identifier); if ($found === false && !empty ($containerSuffix)) { ... } elseif ((integer) $this->modx->getOption('site_start', null, 1) === $found) { ... } else { if ($this->modx->getOption('friendly_urls_strict', null, false)) { $requestUri = $_SERVER['REQUEST_URI']; $qsPos = strpos($requestUri, '?'); if ($qsPos !== false) $requestUri = substr($requestUri, 0, $qsPos); $fullId = $this->modx->getOption('base_url', null, MODX_BASE_URL) . $identifier; $requestUri = urldecode($requestUri); if ($fullId !== $requestUri && strpos($requestUri, $fullId) !== 0) { $parameters = $this->getParameters(); unset($parameters[$this->modx->getOption('request_param_alias')]); $url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full'); $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently')); } } ... } } else { ... } return $identifier; }
Если выбрано «Да», неканонические запросы, соответствующие ресурсу, будут перенаправлены с кодом 301 на канонический URI для этого ресурса. WARNING: Do not enable if you use custom rewrite rules which do not match at least the beginning of the canonical URI. For example, a canonical URI of foo/ with custom rewrites for foo/bar.html would work, but attempts to rewrite bar/foo.html as foo/ would force a redirect to foo/ with this option enabled.
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^test\.html$ resource0.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ resource0.html?q=$1 [L,QSA]