Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.1-backport] Fix trailing slash used in url rewrites #10164

Merged
merged 11 commits into from
Jul 6, 2017

Conversation

ihor-sviziev
Copy link
Contributor

@ihor-sviziev ihor-sviziev commented Jul 6, 2017

My pull request #10043 has been merged to develop branch. This PR adds the same changes to 2.1-develop branch

Description

Admin user configured two URL rewrites in Admin UI. Frontend user may request the page with or without trailing slash. In some case Magento will return 404 page.
We would like to avoid content duplication for the requests with and without trailing slash. If request path has configured url_rewrite (w/ or w/o trailing slash) redirect to this page automatically. If requested path matches configuration, just follow redirect rules.

Fixed Issues (if relevant)

  1. Product URL Suffix "/" results in 404 error #4876 Product URL Suffix "/" results in 404 error
  2. Slash as category URL suffix gives 404 error on all category pages #3872 Slash as category URL suffix gives 404 error on all category pages
  3. Multiple URLs causes duplicated content #4660 Multiple URLs causes duplicated content
  4. Custom URL Rewrite where the request path ends with a forward slash is not matched #8264 Custom URL Rewrite where the request path ends with a forward slash is not matched

Related pull requests

  1. Fix trailing slash used a product URL suffix #7041 Fix trailing slash used a product URL suffix
  2. Fixes problem with url rewrites not being matched when the request path has a trailing forward slash #8319 Fixes problem with url rewrites not being matched when the request path has a trailing forward slash

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

ihor-sviziev and others added 9 commits July 6, 2017 15:17
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).

(cherry picked from commit bddb74c)
Use ternary operators instead of if-else blocks

(cherry picked from commit 30c2c79)
Cover with unit tests

(cherry picked from commit fe77c14)
Cover with unit tests

(cherry picked from commit ac41ad0)
 - covered changes with integration tests

(cherry picked from commit 0ecf635)
 - fixed integration tests

(cherry picked from commit 82e5ebe)
 - added integration tests for CMS pages

(cherry picked from commit 8f031d0)
@okorshenko okorshenko self-assigned this Jul 6, 2017
@okorshenko okorshenko added this to the July 2017 milestone Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants