Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

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.

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());
    .....
}

Frontend

There is no frontend part to document.

  • No labels