www prefix doesnt work on NOPCommerce

72 Views Asked by At

I have developed a website through nopcommerce and everything works just fine, while testing I found that when I add www to my domain www.mydomain.com it doesnt work but when i hit mydomain.com it works just fine.

I found many replies for the same problem but none of them seem to have solved my problem, I also tried below https://blogs.iis.net/owscott/iis-url-rewrite-rewriting-non-www-to-www

by using url rewrite it throws 500 error.

Please help

2

There are 2 best solutions below

0
On

After looking up the domain with www using MXToolbox it was found that no record was found. So suggested fix was to add www cname dns record for the domain by logging into domain provider panel.

0
On

For those who are having difficulties with versions older than 3.9. The problem for me was to specifically set the security url. You must leave it blank in the store configuration (or put without 3w to hack the logic) for nopcommerce to automatically detect it. Because before he checks whether or not 3w exists, he uses the url saved in this field, according to the method GetStoreHost:

if (useSsl)
{
    result = !String.IsNullOrWhiteSpace(currentStore.SecureUrl)
    ?
    // Secure URL is specified. 
    // So a store owner doesn't want it to be detected automatically.
    // In this case let's use the specified secure URL
    currentStore.SecureUrl
    :
    // Secure URL is not specified.
    // So a store owner wants it to be detected automatically.
    result.Replace("http:/", "https:/");
}