...
Note |
---|
Backend documentation and general review is needed. |
List of rewrites
is placed in database in table core_config_data with pathweb/custom_rewrites/rewrites
Router
There is Router class with match method, which checks if there is a match for given url.
If not - nothing happens, if there is - url is redirect to given target
vendor/creativestyle/magesuite-url-rewrite/Controller/Router.php:39
Code Block |
---|
public function match(\Magento\Framework\App\RequestInterface $request)
{
$server = $request->getServer();
$requestUri = $server->get('ORIGINAL_URI') ? $server->get('ORIGINAL_URI') : $request->getRequestUri();
.....
$rewrite = $this->rewriteRepository->getRewrite($requestUri);
if($rewrite == null) {
return null;
}
$this->response->setRedirect($rewrite->getTargetUrl());
$this->response->setStatusCode($rewrite->getStatusCode());
.....
} |
Method getRewrite gets list of rewrites from configuration
Checks if there is entry for requested url, if yes - sets rewrite url as target url
vendor/creativestyle/magesuite-url-rewrite/Repository/RewriteRepository.php:35
Code Block |
---|
public function getRewrite($requestUri) { $rewrites = $this->scopeConfig->getValue('web/custom_rewrites/rewrites', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); ..... $rewrites = explode(PHP_EOL, $rewrites); foreach($rewrites as $rewrite) { $rewrite = explode('|', $rewrite); ..... $originalUrl = ltrim($rewrite[self::ORIGINAL_URL], '/'); $originalUrl = trim($originalUrl); if($originalUrl != $requestUri) { continue; } $targetRewrite = $this->rewriteFactory->create(); $targetRewrite->setTargetUrl($rewrite[self::TARGET_URL]); $targetRewrite->setStatusCode($rewrite[self::STATUS_CODE] ?? self::DEFAULT_STATUS_CODE); return $targetRewrite; } ..... } |
Frontend
There is no frontend part to document.