One more URL redirect problem

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
AlexG
Commander (CMDR)
Commander (CMDR)
Posts: 128
Joined: Mon Mar 03, 2008 9:51 pm
Location: StealDeals.com
Contact:

One more URL redirect problem

Post by AlexG » Thu Jul 08, 2010 10:31 am

Hire is one more problem with redirect:
when the user or bot open the URL like this https://www.test.com/category-name-C8.aspx (with https) or http://test.com/category-name-C8.aspx (without www) this 2 links redirecting to http://www.test.com/Category.aspx?CategoryId=8 - that is wrong - that 2 URLs mus be going to http://www.test.com/category-name-C8.aspx

And the same with product detail URL too:
Open this https://www.test.com/Product-name-P7938.aspx (with https) or http://test.com/Product-name-P7938.aspx (without www) - redirecting to http://www.test.com/Product.aspx?ProductId=7938 - that is wrong too!!
Must going to http://www.test.com/Product-name-P7938.aspx

Help me to fix it.

Thanks,
Alex

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: One more URL redirect problem

Post by mazhar » Fri Jul 09, 2010 6:41 am

You can try using canonical link for search engine. In order to do so edit you website/yourcategorypage.aspx file and then update its load method as below

Code: Select all

protected void Page_Load(object sender, EventArgs e)
    {
        if (_Category != null) PageHelper.BindMetaTags(this, _Category);
        
        StringBuilder htmlHead = new StringBuilder();
        string url = Token.Instance.Store.StoreUrl;
        if (!url.EndsWith("/"))
            url = "/";
        string catUrl = _Category.NavigateUrl;
        if(catUrl.StartsWith("~"))
            catUrl = catUrl.Remove(0,1);
        if(catUrl.StartsWith("/"))
            catUrl = catUrl.Remove(0,1);
        url = url + catUrl;
        string canonicalFormat = "<link rel=\"canonical\" href=\"{0}\" />";
        htmlHead.Append(string.Format(canonicalFormat, url));
        Page.Header.Controls.Add(new LiteralControl(htmlHead.ToString()));
    }

User avatar
AlexG
Commander (CMDR)
Commander (CMDR)
Posts: 128
Joined: Mon Mar 03, 2008 9:51 pm
Location: StealDeals.com
Contact:

Re: One more URL redirect problem

Post by AlexG » Sat Jul 10, 2010 4:53 am

Thanks for help - I've added that code but NO result - I fetch that page as google and get the same error - URL with paramets.
PLEASE HELP ME TO FIX IT

Thanks,
Alex

Post Reply