Skip to content

Commit bddb74c

Browse files
committed
Fix trailing slash used a product & category URL suffix
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).
1 parent 0ee7c9c commit bddb74c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ protected function doFindOneByData($data)
9696

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

100-
// If request path matches the DB value
101-
if ($resultFromDb[UrlRewrite::REQUEST_PATH] === $requestPath) {
101+
// If request path matches the DB value or it's redirect
102+
if ($resultFromDb[UrlRewrite::REQUEST_PATH] === $requestPath
103+
|| in_array((int)$resultFromDb[UrlRewrite::REDIRECT_TYPE], $redirectTypes, true)
104+
) {
102105
$result = $resultFromDb;
103106
} else {
104107
// Otherwise return 301 redirect to request path from DB results

0 commit comments

Comments
 (0)