Skip to content

Commit

Permalink
Fix trailing slash used a product & category URL suffix
Browse files Browse the repository at this point in the history
If request path doesn't match the DB values, if it's redirect (301 or 302) - follow redirect rules from DB results (to have only one redirect); if it's not redirect (category or product page) - redirect to request_path from DB. It will reduce negative effect for SEO and a little bit server load (1 request instead of 2).
  • Loading branch information
ihor-sviziev committed Jun 27, 2017
1 parent 0ee7c9c commit bddb74c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ protected function doFindOneByData($data)

if (count($resultsFromDb) === 1) {
$resultFromDb = current($resultsFromDb);
$redirectTypes = [OptionProvider::TEMPORARY, OptionProvider::PERMANENT];

// If request path matches the DB value
if ($resultFromDb[UrlRewrite::REQUEST_PATH] === $requestPath) {
// If request path matches the DB value or it's redirect
if ($resultFromDb[UrlRewrite::REQUEST_PATH] === $requestPath
|| in_array((int)$resultFromDb[UrlRewrite::REDIRECT_TYPE], $redirectTypes, true)
) {
$result = $resultFromDb;
} else {
// Otherwise return 301 redirect to request path from DB results
Expand Down

0 comments on commit bddb74c

Please sign in to comment.