Hi,
The changes in 7.4 that add canonical urls to each page have caused an issue for me. I ran the IIS SEO tools and noticed that nearly every page was being crawled as http://localhost/category-c1.aspx and also http://localhost//category-c1.aspx - with two forward slashes. I have also noticed in the webmaster tools that Google is also seeing things that way.
I traced the issue to the fact that the canonical link has a %2F in it, instead of a forward slash, which comes from the HttpUtility.UrlEncode method. The only solution I can see is to replace each occurrence of %2F with a forward slash, which has solved the problem. This was done in the BindMetaTags function in PageHelper.cs.
Regards
Rob
Canonical URL Issue - Two Forward Slashes
Re: Canonical URL Issue - Two Forward Slashes
do you have an example of this?
- Shopping Cart Admin
- AbleCommerce Admin
- Posts: 3055
- Joined: Mon Dec 01, 2003 8:41 pm
- Location: Vancouver, WA
- Contact:
Re: Canonical URL Issue - Two Forward Slashes
Hello Rob,
Thanks for the report, we'd identified this a few days ago while working on our new website. A hot patch will be available shortly. I am sorry this was overlooked in the forums and was missed in testing. Please report bugs to our ablecrm system.
Thanks for the report, we'd identified this a few days ago while working on our new website. A hot patch will be available shortly. I am sorry this was overlooked in the forums and was missed in testing. Please report bugs to our ablecrm system.
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: Canonical URL Issue - Two Forward Slashes
The file App_Code/PageHelper.cs has the broken code, around line 480 in the released version of the file. The broken method is BindMetaTags:
To correct it, replace with this code:
Code: Select all
public static void BindMetaTags(Page page, ICatalogable catalogObject)
{
if (catalogObject != null)
{
StringBuilder htmlHead = new StringBuilder();
htmlHead.Append(catalogObject.HtmlHead);
if (!catalogObject.HtmlHead.Contains("<link rel=\"canonical\""))
{
string canonicalFormat = "<link rel=\"canonical\" href=\"{0}\" />";
string objectUrl = page.ResolveUrl(catalogObject.NavigateUrl);
htmlHead.Append(string.Format(canonicalFormat, HttpUtility.UrlEncode(objectUrl)));
}
page.Header.Controls.Add(new LiteralControl(htmlHead.ToString()));
}
}
Code: Select all
public static void BindMetaTags(Page page, ICatalogable catalogObject)
{
if (catalogObject != null)
{
StringBuilder htmlHead = new StringBuilder();
htmlHead.Append(catalogObject.HtmlHead);
if (!catalogObject.HtmlHead.Contains("<link rel=\"canonical\""))
{
Uri storeUri = new Uri(Token.Instance.Store.StoreUrl);
string canonicalFormat = "<link rel=\"canonical\" href=\"{0}\" />";
string objectUrl = storeUri.Scheme + "://" + storeUri.Authority + page.ResolveUrl(catalogObject.NavigateUrl);
htmlHead.Append(string.Format(canonicalFormat, objectUrl));
}
page.Header.Controls.Add(new LiteralControl(htmlHead.ToString()));
}
}
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Re: Canonical URL Issue - Two Forward Slashes
This didn't fix my URL's. Google still is finding my URL's twice. One correctly and one with %2f added. Also, it created a log-in issue with my admin, and for those that were already in the admin, they couldn't save the changes they had made to products because the save button wouldn't show. Can you tell me what I may have done wrong. Has the coding above worked for anyone else? I would assume this must be a problem for everyone isn' t it? I am on Able 7.0.4