Search code examples
jqueryasp.netajaxgoogle-index

Prevent google from indexing Postback Ajax destination


I have a website example.com where I have a number of pages where comments can be made. Instead of using submit/postback to post the comments back to the server, I use Ajax but it seems to have created additional pages.

http://example.com/page
http://example.com/page/postcomment 

It has indexed the postcomment page rather than the one without the postcomment. How can I prevent Google from indexing postback function calls? Below is the Jquery/Ajax function that I call to submit the comment and what Google then going on to index.

$.ajax({ type: "POST", url: '/page/postcomment', dataType: "json", 
data: data, contentType: "application/json; charset=utf-8", 

success: function () { alert('Thanks for commenting, it will be reviewed and uploaded later.'); }, 

error: function (response) { alert(response.statusText); } }); } } });

Solution

  • I'm not sure it is related to SEO. If so, you can create robots.txt at the root level.

    For example,

    User-agent: * 
    Disallow: /*/postcomment
    

    FYI: It will take 24 to 48 hours for Google to index the site again.