Skip to content

More than one redirect with trailing slash in secure non-www url #26177

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

Closed
monotheist opened this issue Dec 25, 2019 · 15 comments
Closed

More than one redirect with trailing slash in secure non-www url #26177

monotheist opened this issue Dec 25, 2019 · 15 comments

Comments

@monotheist
Copy link

Preconditions (*)

  1. Magento 2.3.3
  2. SSL enabled

Steps to reproduce (*)

  1. In Firefox browser enter https://example.com/mens-wear
  2. There is more than one redirect with trailing slash in secure non-www url when you inspect the network tab in firefox browser. As you can see from below a secure non-www url is forwarded to a url with trailing slash and then again forwarded to one with no slash. Please note that other redirects are fine. Issue is only with secure non-www url. Also note that I am using the default nginx conf file that comes with magento installation. I have noticed this on two production stores.

https://example.com/mens-wear
https://www.example.com/mens-wear/
https://www.example.com/mens-wear

Expected result (*)

  1. Only one redirect.

Actual result (*)

  1. More than one redirect.
@m2-assistant
Copy link

m2-assistant bot commented Dec 25, 2019

Hi @monotheist. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@monotheist do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 25, 2019
@Zyles
Copy link

Zyles commented Dec 27, 2019

Check if this helps: #25603

@monotheist
Copy link
Author

@Zyles Thank you. I see solution but I am finding it hard to understand. Could you please help me by pointing exact changes that are required to be done? Much appreciated.

@Zyles
Copy link

Zyles commented Dec 27, 2019

@Zyles
Copy link

Zyles commented Dec 27, 2019

You need to do the rollback in the first link and then apply the changes in the pull request.

You can skip the test files in test directories.

Add lines with + and remove -

@monotheist
Copy link
Author

@Zyles
Copy link

Zyles commented Dec 27, 2019

Could work. Just make a backup of the original file.

@monotheist
Copy link
Author

@Zyles Thank you so much. Essentially I just need to focus on one file which is Router.php in both the links.

@monotheist
Copy link
Author

@Zyles I tried replacing Router.php file from both the links. Cleared cache and restarted php-fpm. My issue still exists.

@Zyles
Copy link

Zyles commented Dec 28, 2019

What is your category suffix setting? And "Auto-redirect to Base URL"?

Is the redirect 302 or 301?

I was unaware that the default nginx conf worked with SSL at all, since it is not even configured to.

I suggest installing a fresh 2.3.3 installation and trying to reproduce it. If you can't it sounds like a nginx config issue.

@monotheist
Copy link
Author

@Zyles Category suffix setting is empty. I don't have anything in there. I am seeing this issue on two live stores. Please see attached image. Fresh install is out of scope. I have separate config for SSL which includes the default magento nginx conf. Please see below.

server {
    listen      443 ssl http2;
    server_name example.com www.example.com;
    ssl_protocols       TLSv1.2  TLSv1.3;

    ssl_certificate      /usr/local/vesta/ssl/certificate.crt;
    ssl_certificate_key  /usr/local/vesta/ssl/certificate.key;

    access_log  /var/log/nginx/domains/example.com.log combined;
    access_log  /var/log/nginx/domains/example.com.bytes bytes;
    error_log   /var/log/nginx/domains/example.com.error.log error;

    location / {
        proxy_pass http://127.0.0.1:6081;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Ssl-Offloaded "1";
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen    8080;
    server_name example.com www.example.com;
    set $MAGE_ROOT /home/example/web/example.com/public_html/pub;
    set $MAGE_MODE production; # or production

    include	/home/example/web/example.com/public_html/nginx.conf.sample;
    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;
    include     /home/example/conf/web/snginx.example.com.conf*;
}

Screenshot 2019-12-28 at 10 17 10 AM
Screenshot 2019-12-28 at 10 27 21 AM

@Zyles
Copy link

Zyles commented Dec 28, 2019

You need to verify the issue on a fresh 2.3.3 install to determine if it is a M2 or nginx configuration issue or one of your extensions.

@ghost ghost added Issue: ready for confirmation and removed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Oct 21, 2020
@stale
Copy link

stale bot commented Jan 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale issue label Jan 5, 2021
@stale stale bot closed this as completed Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants