Page 1 of 2

issue with URL rewrite?

Posted: Mon Apr 14, 2008 12:25 am
by meer2005
I noticed this major issue when navigating around my development site on my local machine. Anytime that you don't navigate to a product with the left nav (landing on the product page via search, top sellers, related, etc.), it doesn't rewrite the URL with the category at the end. Each URL should be the same as 5.5 with http://www.site.com/productname-PxxCxx.aspx so all the product pages already indexed remain the same for the search engines without doing 301 redirects.

Here's an example on Joe's site:

When I navigate to this product with his left navigation, I get this URL:
Home > Safety and Rescue > Liferafts > Revere Coastal Compact™ 2 Person Life Raft:
http://www.solunar.com/Revere-Coastal-C ... 3C419.aspx (same rewrite as 5.5)


However, if I do a search for Item # 31597, I end up with this URL for the same product:
http://www.solunar.com/Revere-Coastal-C ... 20303.aspx


Anyways, I hope there is a quick fix to this. I'd be curious to see how search engines and the sitemap are treating this??

Re: Big problem with URL rewrite

Posted: Mon Apr 14, 2008 6:56 am
by AbleMods
Here's how I understand it:

The URL rewrite is based on the calling point for the product so product-specific or category-specific theming or functionality can be accomplished.

If the visitor calls the product page from a category page, the URL is rewritten to include both the Product Id and the Category Id values. This is done for a number of reasons both programming-wise and SEO-wise.

Since a single product can exist in multiple categories, the site admin needs the ability to link a given product to a specific end-point mapping that includes not just the product Id, but also what category is involved. This gives a developer a great deal of flexibility to alter the site content or functionality based on the category involved. It also gives a site admin the ability to advertise specific landing pages and thus allow category-based theming to be practically automatic.

When a product is "directly" referenced, i.e. from the SimpleSearch user control, there is no category involved. So the rewriter just builds a product Id based URL and calls it a day. That's why each product record has a default theme to fall back upon in the event a product record is called without a category being explicitely chosen first.

I agree with you that it could be a point of concern when focusing on specific SEO optimization techniques. But the site-design flexibility that is possible with such an implement is enormous and I think that will be worth down-the-road.

Just my 2-cents worth.... ;)

Re: Big problem with URL rewrite

Posted: Mon Apr 14, 2008 9:29 am
by jmestep
This happened some in 5.5-- products were assigned a Category 0 in some places. It was easier to change there because on of the category ids was in the products table. I'll do some digging here.

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 12:01 pm
by meer2005
My main concern would be the search engines seeing the pages as duplicate content, which would just cause the pages to be dropped from the index completely. Obviously dropped pages would be to the contrary to what is probably everyone's goal, having every page indexed on the search engines. Google has a page on duplicate content here: http://www.google.com/support/webmaster ... swer=66359

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 12:14 pm
by Logan Rhodehamel
Duplicate content is one of the problems with the category linking in the first place.

Category A
- Widget
Category B
- Widget

If you have two links to the same widget from different entry points, search engines are not going to like that. In AC55 that product would have two different links with (probably) the same content. Instead in this version we do something different to track the category entry point in case we have to display a breadcrumb or switch the theme. That way the link to the product is always the same.

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 12:15 pm
by AbleMods
The question becomes how did the bots learn about your page? Bots aren't going to brute-force keyword your SimpleSearch control, so you're pretty safe there.

I think the greatest risk would be when a bot crawls the sitemap.xml file, then tries to crawl the "Product Finder" feature of a default AC7 install, and finally crawls the category links you've built into whatever site menu implementation you have. Product pages discovered via product finder will not have the same URL as products discovered via a category or sub-category link located elsewhere on your site.

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 12:18 pm
by Logan Rhodehamel
Whoops.. I misread the post and I see our category linked products have the C### in the url. I wonder why... I think it would be best if we did NOT include them. Maybe it was done for backward compatibility reasons, merchants not wanting the product links to change. I will have to find out.

AC7 by default includes robots.txt to restrict what well-behaved spiders will look at. We can make adjustments to that if it turns out spiders (e.g. google) are looking somewhere that gives a duplicate content problem. I can also probably give you guys a tweak that would always include a category ID in the URL.

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 12:52 pm
by jmestep
Logan, the category id in the URL occurs some places and not others- some of it is dependent on what category grid is used. I few weeks ago there were some posts on it and I know I prefer having it in the URL so that it will match links from 5.5 that are already in the search engines and so that I can get the category id easily for other purposes from just looking at the URL.

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 1:32 pm
by meer2005
If you could add that tweak to make it so the cat id is always displayed, that would be great!

If it was just the search or the product finder, I wouldn't be too concerned. The problem is every time a product is displayed outside the category it belongs, it doesn't include the category on the URL. For me, this happens in multiple places, starting with my home page, category pages, and product pages...... Specifically in featured items on my home page, top sellers and recently viewed on my category pages, and more items in..... at the bottom of product pages.

Re: issue with URL rewrite?

Posted: Mon Apr 14, 2008 6:31 pm
by jmestep
I have found out that different category grid controls use different ways of displaying the product url on that category page. That is why sometimes the category id shows up in the url and sometimes it doesn't. Here are two examples:
itemTemplate1.Controls.Add(new LiteralControl(string.Format("<a href=\"{0}\" class=\"highlight\">{1}</a><br />", catalogNodeUrl, catalogNode.Name)));

itemTemplate1.Controls.Add(new LiteralControl(string.Format("<a href=\"{0}\" class=\"highlight\">{1}</a><br />", productUrl, product.Name)));

The top one shows the category id and the bottom one doesn't.
The searchpage.ascx.cs uses this:
itemTemplate1.Controls.Add(new LiteralControl(string.Format("<a href=\"{0}\" class=\"highlight\">{1}</a><br />", productUrl, product.Name)));


The .cs files that use the catalogNodeURL have using CommerceBuilder.Catalog; in the file and catalog node code toward the top of the page.
Maybe Logan can tell us how to implement that on search page, etc for those of us who want it?

Re: issue with URL rewrite?

Posted: Wed Apr 16, 2008 10:17 am
by Logan Rhodehamel
If the link is coming from Product.NavigateUrl, then it won't have a category ID within. This is because we assume the category ID is not known.

Take the example of ConLib/SearchPage.ascx.cs. Within ProductList_ItemDataBound method is where the URL for the product link gets set:

Code: Select all

string productUrl = this.Page.ResolveClientUrl(product.NavigateUrl);
Instead, we could call the underlying URL generator and specify what category we want to include in the link:

Code: Select all

                string productUrl;
                if (product.Categories.Count > 0)
                {
                    productUrl = CommerceBuilder.Catalog.UrlGenerator.GetBrowseUrl(product.Categories[0], product.ProductId, CommerceBuilder.Catalog.CatalogNodeType.Product, product.Name);
                }
                else productUrl = product.NavigateUrl;
                productUrl = this.Page.ResolveClientUrl(productUrl);
This just takes the first category in the list and includes it in the URL. I have to get going on another project for today but maybe someone can take this info and run with it?

Re: issue with URL rewrite?

Posted: Fri Apr 25, 2008 11:43 am
by meer2005
This works for the search page, but how can this be done for the other places on the site where the cat is not included in the url?

For example: ConLib:FeaturedProductsGrid
- doesn't show the cat in the url... anyone figure this out yet?

Re: issue with URL rewrite?

Posted: Sat May 03, 2008 5:56 am
by m_plugables
Add the following functions in App_Code/PageHelper.cs file

Code: Select all

public static string GenerateLink(string productId, Page page)
    {
        Product product = ProductDataSource.Load(AlwaysConvert.ToInt(productId));
        return GenerateLink(product, page);
    }

    public static string GenerateLink(int productId,Page page)
    {
        Product product = ProductDataSource.Load(productId);
        return GenerateLink(product,page);
    }
    public static string GenerateLink(Product product,Page page) 
    {
        string productUrl;
        if (product.Categories.Count > 0)
        {
            productUrl = CommerceBuilder.Catalog.UrlGenerator.GetBrowseUrl(product.Categories[0], product.ProductId, CommerceBuilder.Catalog.CatalogNodeType.Product, product.Name);
        }
        else productUrl = product.NavigateUrl;
        productUrl = page.ResolveClientUrl(productUrl);
        return productUrl;
    }
Now you can use these function to generate a link with CategoryId by using any of the following. In fact it depends upon what is available where you want to generate the link. For example in the search page you already have the product object so you can use option 3

1- You have product id in the query string

Code: Select all

     string productUrl = GenerateLink(PageHelper.GetProductId(),this.Page);
2- You have product id for example productId

Code: Select all

     string productUrl = GenerateLink(productId,this.Page);
3- You have actual product object for example in many pages we have _Product

Code: Select all

     string productUrl = GenerateLink(_Product,this.Page);

Re: issue with URL rewrite?

Posted: Wed May 14, 2008 12:29 pm
by meer2005
Why is this not the same throughout the site? I just did a data import from a 5.5 store into a 7.0 store and all the products were displayed on the category pages without the Cat ID in the URL. Turns out that "Category Grid Page" doesn't have the Cat Ids in the URL, but "Category Grid Page 2" does have the Cat Ids in the URL.

Then all of these don't show the Cat ID in the URL:

ConLib/
alsobought.ascx
ItemBought.ascx
FeaturedProductsGrid.ascx
MoreCategoryItems.ascx
NewestProductsDialog.ascx
PopularProductsDialog.ascx
ProductAccessoriesGrid.ascx
RelatedProducst.aspx
SimilarProducts.ascx

From an SEO perspective, people coming from 5.5 should want the Cat id included in the URL because that’s how it was in 5.5. I know that we have 1000’s of pages that have been indexed for a couple of years now with great positions in the search engines. Leaving the Cat id out of the URL changes it, and would cause us or anyone to do a ton of 301 redirects in order to make it a smooth transition from 5.5 to 7.0, while preserving good search engine positions built up over the years.

Depending what options people select, they could have different URLs all over the site for the same product. Some places showing up with the Cat ID and others without. This can’t be good for the search engines.

For us, I thought we pretty much had it fix after selecting the "Category Grid Page 2" for the Cat page and editing all the Conlib controls to show the Cat Id in the URL when displayed.

That’s what I thought... I did a test sitemap today and found that the Cat Ids are not in any of the product links on the sitemap. So I have all the links on my site displaying with the Cat Id, but the sitemap would be submitted without the Cat Ids in the URLs. Wouldn’t make much sense doing that.

Maybe in this can be straightened out in a future release. Or an option to either have the Cat ids in the URLs or not to have them included….

Re: issue with URL rewrite?

Posted: Wed May 14, 2008 4:21 pm
by jmestep
The existing product links in search engines will still go to the correct product page without the C in the URL- I've tested it on an old site and an AC7 site with the same products.
That is good, but when the sitemap for the new site is generated and it doesn't have C in the URL, search engines might think that we have thousands of pages of duplicate content.
I agree that there should be something standardized on all the category pages. Maybe two different people wrote the code?

Re: issue with URL rewrite?

Posted: Tue May 20, 2008 3:15 am
by m_plugables
There were some problems with the code old posted code. Here is the updated version.

Code: Select all

public static string GenerateLink(int productId, Page page,bool isServerControl)
    {
        Product product = ProductDataSource.Load(productId);
        return GenerateLink(product, page,isServerControl);
    }

    public static string GenerateLink(int productId, Page page)
    {
        Product product = ProductDataSource.Load(productId);
        return GenerateLink(product, page, false);
    }

    public static string GenerateLink(Object product, Page page, bool isServerControl)
    {
        return GenerateLink((Product)product, page,isServerControl);
    }

    public static string GenerateLink(Object product, Page page)
    {
        return GenerateLink((Product)product, page, false);
    }

    public static string GenerateLink(Product product, Page page, bool isServerControl)
    {
        string productUrl;
        if (product.Categories.Count > 0)
        {
            productUrl = CommerceBuilder.Catalog.UrlGenerator.GetBrowseUrl(product.Categories[0], product.ProductId, CommerceBuilder.Catalog.CatalogNodeType.Product, product.Name);
        }
        else productUrl = product.NavigateUrl;
        if(!isServerControl)
            productUrl = page.ResolveClientUrl(productUrl);
        return productUrl;
    }
If you are creating some link for some asp.net control then use any of above overloaded function with isServerControl parameter having value true.

Re: issue with URL rewrite?

Posted: Tue Jun 03, 2008 10:15 am
by ajasko
I need to switch from my old cart and host to this AbleCommerce Release soon, and to do that I need to do hundreds of 301 page redirects from my old urls to the new urls, since all my pages are indexed in google and I cannot afford to lose them. Thus, I need to know which urls to redirect to in AbleCommerce. Should I use urls with just the P ids (as is default in the store and sitemap - I like this way better), or should I use the urls with P ids and C ids? I need to know if this is going to change or stay the same in future releases, because if it changes I will have to change everything again. Anyone know?

Re: issue with URL rewrite?

Posted: Tue Jun 03, 2008 12:21 pm
by jmestep
For a product URL, the link goes to the correct product whether there is a C in the URL or not.
I just checked a feed for Googlebase and it is generated with only the P in the URL. The sitemap.xml is generated with only the P also. I would go with that (P only) because the code to generate the Googlebase feed is in the source code where we can't change it so if you do that and also put up the same products with a C in the URL, you would get duplicate links.

Re: issue with URL rewrite?

Posted: Thu Jun 05, 2008 11:30 am
by ajasko
Judy, you are probably the most helpful person in the whole entire world. Seriously

Re: issue with URL rewrite?

Posted: Fri Jun 27, 2008 1:43 pm
by jmestep
I think I'm going to have to switch my products to be uniform - either C or no C in all product URLS. I hadn't checked that yet. I was looking in my Google sitemap reports and found a lot of these issues.

Re: issue with URL rewrite?

Posted: Sat Jun 28, 2008 10:02 am
by jmestep
Logan, can you give us the reverse of this- code to change on the catgory pages where there is a C generated in the URL? I'm going to have to go with trying to have no C's in the URL because there are so many places the C isn't generated, like the product feeds.

Code: Select all

string productUrl;
                if (product.Categories.Count > 0)
                {
                    productUrl = CommerceBuilder.Catalog.UrlGenerator.GetBrowseUrl(product.Categories[0], product.ProductId, CommerceBuilder.Catalog.CatalogNodeType.Product, product.Name);
                }
                else productUrl = product.NavigateUrl;
                productUrl = this.Page.ResolveClientUrl(productUrl);

Re: issue with URL rewrite?

Posted: Sat Jun 28, 2008 11:52 am
by Logan Rhodehamel
Judy, what you want is probably this:

Code: Select all

                string productUrl = product.NavigateUrl;
                productUrl = this.Page.ResolveClientUrl(productUrl);

Re: issue with URL rewrite?

Posted: Tue Jul 01, 2008 2:19 pm
by meer2005
Just so you know, adding the C to all pages still causes problems if you have products in multiple categories. We've changed our site so it displays the C on all product pages to preserve all of our indexed pages without doing 301 redirects. But, 7.0 It's not like 5.5 where you could select a parent category with the radio option and secondary categories with check marks. If you're like us and cross-sale a ton of items in more than one category, then you're going to end up with a different URL for each of the categories that the particular item is in.

Unless the category structure is changed to something like 5.5 where the rewrite looks at some sort of parent category so it isn't creating duplicate pages in every category that the product is in, we're going to have to switch to a P only and do a TON of 301 redirects.

Has anyone done 301 redirects in bulk for dynamic pages in IIS? Is there any way to do it like apache does with an .htaccess file?

Re: issue with URL rewrite?

Posted: Tue Jul 01, 2008 4:27 pm
by jmestep
I'm switching to P only so there won't be duplicates. I think it might mess up navigating up a category to see what else is in that same category, but I'm not sure. I did run across some code in a 5.5 store that came from 4.x where they had set up an .htaccess file for redirects. It starts out like:
# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.31

You might want to see if you can track something down on Helicon.

Re: issue with URL rewrite?

Posted: Tue Jul 01, 2008 6:35 pm
by sacards.com
is there an official fix to this huge SEO problem ?