Page 1 of 1

One more URL redirect problem

Posted: Thu Jul 08, 2010 10:31 am
by AlexG
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

Re: One more URL redirect problem

Posted: Fri Jul 09, 2010 6:41 am
by mazhar
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()));
    }

Re: One more URL redirect problem

Posted: Sat Jul 10, 2010 4:53 am
by AlexG
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