URL redirect

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

URL redirect

Post by heinscott » Tue Jun 16, 2009 7:09 am

I have what I hope is an easy question...
We would like to have our home page, when someone types it in WITHOUT the www in front, resolve to the www version, but, without the default.aspx at the end.
So example:
in address bar, type... poolgeek.com
should resolve to: www.poolgeek.com
Right now, the address resolves to www.poolgeek.com/default.aspx. Because it is a different URL, google will see the non-www address and the www address differently, thus splitting SEO strength of the home page.
Would anyone know of anyway to resolve this? I've tried multiple able commerce site, and all of them appear to have this problem.
Thanks for helping with this!

Scott

kastnerd
Commodore (COMO)
Commodore (COMO)
Posts: 474
Joined: Wed Oct 22, 2008 9:17 am

Re: URL redirect

Post by kastnerd » Tue Jun 16, 2009 8:19 am

With google webmasters you can setup your domain to be with or with out the www's
http://www.google.com/webmasters/ This should prevent any problems with SEO

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: URL redirect

Post by heinscott » Tue Jun 16, 2009 8:59 am

Not what I'm talking about...
I undertand about google and webmaster tools.
I just need to have poolgeek.com resolve to www.poolgeek.com, not www.poolgeek.com/default.aspx.
Any ideas?

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: URL redirect

Post by heinscott » Wed Jun 17, 2009 6:44 am

Mazhar, any ideas on this? If I need to make changes to the source, I can do that. I'm just not sure exactly where to look.
Thanks

Scott

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

Re: URL redirect

Post by mazhar » Wed Jun 17, 2009 7:27 am

Scott I am not sure but it seems that its due to redirection imposed by our licensing module. When some one types domain name without www, I mean poolgeek.com then application redirects it http://www.poolgeek.com/Default.aspx. So I don't think so that you can fix it via code, have a look IIS redirection may be it workout. I will discuss it with Logan as well.

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: URL redirect

Post by heinscott » Wed Jun 17, 2009 7:53 am

Thanks for the help, Mazhar! I appreciate your taking the time to help me out with this. I will look at the IIS redirection and see if I can come up with anything in the meantime.
Thanks again.

Scott

dappy2
Commander (CMDR)
Commander (CMDR)
Posts: 114
Joined: Wed Jan 18, 2006 5:53 pm
Contact:

Re: URL redirect

Post by dappy2 » Wed Jun 17, 2009 8:00 am

You could probably fix this in reverse.

Redirect www.URL.com to www.URL.com/default.aspx

That way Google will see them as the same URL.

TTMedia
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 83
Joined: Mon Dec 03, 2007 11:49 am

Re: URL redirect

Post by TTMedia » Fri May 07, 2010 3:37 pm

Sorry the solution I posted is not right. It caused issues for me with products on my homepage
Last edited by TTMedia on Thu May 13, 2010 12:19 pm, edited 1 time in total.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: URL redirect

Post by michael.p.larsen » Mon May 10, 2010 8:41 am

Might be able to fix it with a HTTP Module.

Code: Select all

using System;
using System.Web;

/// <summary>
/// Summary description for RedirectURL
/// </summary>

    public class RedirectURL : IHttpModule
    {
        void IHttpModule.Dispose()
        {
            // Nothing to dispose; 
        }

        void IHttpModule.Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = sender as HttpApplication;

            if (app.Request.RawUrl.ToLower().Contains("poolgeek.com/default.aspx"))
            {
                    app.Response.Redirect("www.poolgeek.com", true);
            }
        }
}
Then, add to your web.config:

Code: Select all

    <httpModules>
      <add name="RedirectURL" type="RedirectURL" />
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="AbleCommerceHttpModule" type="CommerceBuilder.Services.AbleCommerceHttpModule, CommerceBuilder.Services" />
    </httpModules>

Make sure and do some hefty testing tho. If there are any other redirects in place, you might end up in an infinite loop.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: URL redirect

Post by michael.p.larsen » Tue May 11, 2010 8:23 am

Did you get this fixed? What did you end up doing?

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

Re: URL redirect

Post by mazhar » Thu Jul 08, 2010 10:11 am

A possible workaround for SEO purpose could be to add canonical URL to default page for search engine. For example you can edit Website/Default.aspx.cs file and locate following code line

Code: Select all

<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls.WebParts" TagPrefix="cb" %>
and then update it as below

Code: Select all

<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls.WebParts" TagPrefix="cb" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder htmlHead = new StringBuilder();
Uri storeUri = new Uri(Token.Instance.Store.StoreUrl);
string canonicalFormat = "<link rel=\"canonical\" href=\"{0}\" />";
string objectUrl = storeUri.Scheme + "://" + storeUri.Authority + Page.ResolveUrl("~/");
htmlHead.Append(string.Format(canonicalFormat, objectUrl));
Page.Header.Controls.Add(new LiteralControl(htmlHead.ToString()));
}
</script>
This will automatically add canonical URL to default page pointing to your domain name.

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

Re: URL redirect

Post by AlexG » Fri Jul 09, 2010 12:47 am

I've added that code but it's not working on my side.

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

Re: URL redirect

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

This code changes the canonical URL which is hidden information on page. You will still see Default.aspx in address bar but it will emit your domain name in page HTML as canonical URL. If there is some canonical URL present in page HTML then search engine uses that link to index that page.

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

Re: URL redirect

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

I try to Fetch the page withuot WWW (http://mysite.com) as Googlebot and find out that page redirect (301 Moved Permanently) to http://www.mysite.com:80/default.aspx - but I need that returned the page http://www.mysite.com:80 without default.aspx - the same with HTTPS.
Help me to fix it PLEASE!

Thanks,
Alex

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

Re: URL redirect

Post by AlexG » Wed Jul 14, 2010 1:38 pm

Does anybody know how to fix it?

User avatar
mikek
Commander (CMDR)
Commander (CMDR)
Posts: 112
Joined: Wed Oct 15, 2008 9:30 pm
Location: Boston, MA
Contact:

Re: URL redirect

Post by mikek » Wed Jul 14, 2010 4:02 pm

Hi Alex,

If the site is running on your own dedicated server you can setup http://www.poolgeek.com and poolgeek.com as separate sites in IIS. The site under http://www.poolgeek.com will
be the main site pointing to the AbleCommerce applicaiton, the second site under poolgeek.com will have only a default.aspx page with simple 301 redirect code:

Code: Select all

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location", "http://www.poolgeek.com");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="PageForm" runat="server"></form>
    </body>
</html>

With this setup all requests sent to : http://poolgeek.com will be automatically forwarded to http://www.poolgeek.com. The 301 redirect is also CEO friendly and will be properly recognized by all SE.
Mike Kolev

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

Re: URL redirect

Post by AlexG » Wed Jul 14, 2010 7:52 pm

I open http://poolgeek.com - return me http://www.poolgeek.com/default.aspx !?
mikek wrote:Hi Alex,

If the site is running on your own dedicated server you can setup http://www.poolgeek.com and poolgeek.com as separate sites in IIS. The site under http://www.poolgeek.com will
be the main site pointing to the AbleCommerce applicaiton, the second site under poolgeek.com will have only a default.aspx page with simple 301 redirect code:

Code: Select all

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location", "http://www.poolgeek.com");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="PageForm" runat="server"></form>
    </body>
</html>

With this setup all requests sent to : http://poolgeek.com will be automatically forwarded to http://www.poolgeek.com. The 301 redirect is also CEO friendly and will be properly recognized by all SE.

User avatar
draneb
Captain (CAPT)
Captain (CAPT)
Posts: 314
Joined: Sun Jun 12, 2005 4:07 pm
Location: Texas
Contact:

Re: URL redirect

Post by draneb » Tue Aug 03, 2010 11:38 am

Hi Mazhar,

I have two questions. Well the first is related to the code below.
1) I don't see a Default.aspx.cs file. Did you mean just the Default.aspx file?
mazhar wrote:A possible workaround for SEO purpose could be to add canonical URL to default page for search engine. For example you can edit Website/Default.aspx.cs file and locate following code line
Google Webmaster Tools is hitting me with duplicate content again, which is how I found your post. My URLs in their index went from over 2500 to 625.
They have me 3 times for my home page.
/
/default.aspx and
/Default.aspx

I can't believe Google can't distinguish uppercase and lowercase (so it seems).

2) What code could I use to add the canonical reference to other pages I created such as ContactUs.aspx? I tried the same code but it only listed my domain name url and not the ContactUs.aspx part.

All my duplicate content they have listed are pages like
contactus.aspx
ContactUs.aspx

Thank you very much!
AC 7.0.3 build 13937

Post Reply