UrlRewrite

https://github.com/magesuite/url-rewrite

This module adds the possibility to provide a list of custom URL rewrites.

Installation

This module is part of MageSuite metapackage

Optional installation when metapackage is not used

composer require "creativestyle/magesuite-url-rewrite" ^1.0.0

Admin settings

Admin settings are placed in the:

Stores -> Configuration -> General -> Web -> Custom Rewrites

Settings

List of rewrites

Provide one rewrite per line in format: "{original_path}|{target_path}|{status_code}"
{status_code} is optional and will default to 301.

Example

entry:

/de_de/madchen/babys-gr.-50-92-/jacken-overalls/overalls.html|/de_de/madchen.html

means:

http://magesuite.me/de_de/madchen/babys-gr.-50-92-/jacken-overalls/overalls.html

will redirect to:

http://magesuite.me/de_de/maedchen.html

Backend

Backend documentation and general review is needed.

List of rewrites

is placed in database in table core_config_data with path web/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
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

Frontend

There is no frontend part to document.