_webHelper.GetStoreLocation(false) is hard coded. Should it be?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hello Everyone!

I'm working on nopCommerce 3.60, and I have a doubt regarding the redirecting done on the GetRouteData inside GenericPathRoute controller.

In case you hit a product slug that is inactive, code will redirect you to the most up to the date version of the URL.

Redirecting is done through this code:

var response = httpContext.Response;
response.Status = "301 Moved Permanently";
response.RedirectLocation = string.Format("{0}{1}", webHelper.GetStoreLocation(false), activeSlug);
response.End();

In my case, the website is running on a SSL website, and the redirecting to HTTPS is done through the webconfig.

When you hit webHelper.GetStoreLocation(false), even in secure environment, it will redirect me first to the HTTP version, and then to the HTTPS version, creating two redirects.

Multiple redirects for one product is bad for SEO, so I want to fix this. This could be done easily by setting to true with a store setting the method GetStoreLocation.

My doubt is: Do we have to make it so that the false is passed for a reason, or is it safe to do this change? It is a very simple mistake, and this sort of code usually makes me think twice before making a change.

Thanks!
7 years ago
You're absolutely right. Fixed. Thanks!

mdrj10 wrote:
...the redirecting to HTTPS is done through the webconfig...

By the way, you can enable it in admin area > configuration > settings > general settings > "Force SSL for all site pages" checkbox
7 years ago
Thank you very much Andrei!

And about the setting, we have a database limitation, that's why we are using it through the config only on production. But thanks again for the advice!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.