Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 14 of 14

Thread: Robots.txt Question

  1. #1
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default Robots.txt Question

    I have recently noticed that when I look at our indexed pages in Google urls are starting to show up with the https:// prefix. This is causing pages to show up twice now one for http:// and one for https://

    I looked all over my site trying to figure out how Google got to a link with https:// to start with. I realized it was coming in from the ShoppingCart.aspx page. The default robots.txt file you put with the cart disallows /shoppingcart.aspx, but the robots.txt file is case sensitive. I changed it to the correct case and now Google can not get there.

    Now I need to try and get those pages that were indexed with https:// de-listed. I did some research and this seems to be the best method to get this worked out:


    Use url rewrites to 301 redirect the https pages to the http pages.
    OR
    1. Add NOINDEX, NOARCHIVE to all https pages.
    2. When google crawls the pages they'll drop out
    3. Create a robots.txt file for secure and non-secure pages. Disallow all bots on the ssl one.

    I am not sure how to use the ISAPI rewrite to do this. Anyone know how to do it that way? The rewrites I use are setup in this fashion:
    RewriteRule /old-page.aspx /new-page.aspx [I,RP]

    If I put this it does not work:
    RewriteRule https://www.site.com/old-page.aspx http://www.site.com/new-page.aspx

    The second solution listed I am not sure how to add the meta tag NOINDEX, NOARCHIVE to just the https pages. I have this code, but don't know how to get it put into the templates:

    if (Request.ServerVariables["HTTPS"] == "on") {
    Response.Write("<meta name=\"robots\" content=\"nofollow,noindex,noarchive,nocache\" />");
    }

  2. #2
    Rex is offline Banned
    Join Date
    Nov 2007
    Posts
    561

    Default

    add a Literal control to the head section of your template.ascx of your skin.

    In App_Code\TemplateBase.cs add your check in the Page_Load method, setting the Text property of the Literal control if you need to supply the meta information.

  3. #3
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default

    Quote Originally Posted by ASPDNSF Staff - Rex View Post
    add a Literal control to the head section of your template.ascx of your skin.

    In App_Code\TemplateBase.cs add your check in the Page_Load method, setting the Text property of the Literal control if you need to supply the meta information.
    Do I need the source code to do this?

  4. #4
    ASPDNSF Staff – Eirol is offline Senior Member
    Join Date
    May 2008
    Posts
    182

    Default

    The file template.ascx is located on your sites Skin folder while the TemplateBase.cs is located on the App_Code folder..
    Last edited by ASPDNSF Staff – Eirol; 09-18-2008 at 07:22 PM.

  5. #5
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default

    I have the literal control placed in my template file, but changing it in the TemplateBase.cs file is not working out for me.

    I have just a basic if test I put in there:

    HTML Code:
    if (Request.ServerVariables["HTTPS"] == "on")
    {
      Literal1.Text = "name='ROBOTS' content='NOINDEX, NOFOLLOW, NOARCHIVE'";
    }
    Doing that gives me this compilation error:

    HTML Code:
    Compilation Error
    
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
    
    Compiler Error Message: CS0103: The name 'Literal1' does not exist in the current context

  6. #6
    Rex is offline Banned
    Join Date
    Nov 2007
    Posts
    561

    Default

    Doesn't sound like you added the Literal to the template correctly. Try sharing that bit with us.

  7. #7
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default

    Quote Originally Posted by ASPDNSF Staff - Rex View Post
    Doesn't sound like you added the Literal to the template correctly. Try sharing that bit with us.
    Here is what I have in my template file:

    HTML Code:
    <meta <asp:Literal ID="Literal1" runat="Server" Text="name='ROBOTS' content='INDEX,FOLLOW'"></asp:Literal>>

  8. #8
    Rex is offline Banned
    Join Date
    Nov 2007
    Posts
    561

    Default

    that's not going to work like that.

    You cannot hide a tag inside a tag.

    You need
    Code:
    <asp:Literal ID="Literal1" runat="server"/>

    And in your code:

    Code:
    Literal1.Text = "<meta blah blah />";

  9. #9
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default

    Quote Originally Posted by ASPDNSF Staff - Rex View Post
    that's not going to work like that.

    You cannot hide a tag inside a tag.

    You need
    Code:
    <asp:Literal ID="Literal1" runat="server"/>

    And in your code:

    Code:
    Literal1.Text = "<meta blah blah />";
    Okay I set it up this way and I still get this error:

    HTML Code:
    Compilation Error
    
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
    
    Compiler Error Message: CS0103: The name 'Literal1' does not exist in the current context

  10. #10
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default

    Quote Originally Posted by ASPDNSF Staff - Rex View Post
    add a Literal control to the head section of your template.ascx of your skin.

    In App_Code\TemplateBase.cs add your check in the Page_Load method, setting the Text property of the Literal control if you need to supply the meta information.
    This is how my code is currently:

    TemplatBase.cs (Page_load method)
    Code:
    if (Request.ServerVariables["SERVER_PORT_SECURE"] == "1")
    {
    	Literal1.Text = "<meta name='ROBOTS' content='NOINDEX, NOFOLLOW, NOARCHIVE'>";
    }
    else
    {
    	Literal1.Text = "<meta name='ROBOTS' content='INDEX,FOLLOW'>";
    }
    home-template.ascx
    Code:
    <asp:Literal ID="Literal1" runat="Server" Text=""></asp:Literal>

  11. #11
    rizzy is offline Member
    Join Date
    Aug 2007
    Posts
    56

    Default

    I created a test page that had nothing on it except the code from above and it worked properly.

    I am not sure what is causing it to mess up when I put it into the storefront code.

  12. #12
    Bartman is offline Junior Member
    Join Date
    Oct 2009
    Location
    North Carolina
    Posts
    3

    Default

    Rizzy,

    We have the exact same problem with our ASPDNSF site (ShoppingCart.aspx instead of shoppingcart.aspx inside the case-sensitive robots.txt file, causing many pages to show up as https in the rankings and thus causing a security certificate warning/error when clicked).

    Did you ever have success placing the "nofollow noindex no archive" meta tag on the secure pages?

  13. #13
    sasdaman is offline Member
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    35

    Default

    Hi peps,

    Like Bartman i'm also interested in a solution. Was this ever resolved? If so could the solution be posted on here pleaseeeeeeeee !

    Kind regards,
    Sahus Pilwal
    Web Designer
    eCommerce Design & Development

  14. #14
    Mike Sollars is offline Junior Member
    Join Date
    Aug 2005
    Posts
    6

    Default Same Problem

    Anyone figure this out?