I use jQuery for a simple website and have the main page 'index.html' which can load some content (e.g. 'info1.html' or 'info2.html') via ajax jQuery queries and display the result of these queries inside the element on the page "index.html".
If the user somehow visits, say, "info1.html" directly, is there a way to redirect or load the main page "index.html"? (or what works best for this type of thing), since Google indexes all the small html files used for ajax requests, and sometimes the user can click on the site through these pages.
Thank.
Workaround 1:since jquery will select the content inside the body tag by default, you can add a head a script to the element to redirect you to the main page or meta tag (or rather), as Daniel mentioned.
Workaround 2:if your ajaxed files are in a folder, you can use the robots.txt file and google direct to not index the pages in these folders.
or you can do it directly from within these pages (see http://en.wikipedia.org/wiki/Noindex )
You can use the meta refresh tag:
<html> <head> <meta http-equiv="refresh" content="0; url=http://mydomain.com/main.html"> </head> <body> <div> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad eleifend option congue nihil imperdiet doming id quod mazim.</p> </div> </body> </html>
info1.html info2.html. :
$.ajax({ type: "POST", url: "info1.html", data:myParameter=1, success: function(html){ ......... } });
info1.html , myParameter 1. , . , javascript. , info1.html URL-, . , PHP. , info1.php info2.php
, :
XML, HTML.
html, , window.onload java script :
window.onload = function() {window.location.href = 'http://www.google.com';}
Source: https://habr.com/ru/post/1737621/More articles:Rhino Mocks, dependency injection and separation of problems - dependency-injectionЧто происходит, когда я подписываюсь на сообщение с помощью NServiceBus? - messagingeven PHP has "errors" with IE - mime-typesConvert HTML to PDF from ASP classic hosting? - pdf-generationMaven problem with invalid jar file, which is actually html - repositoryHelp with Kohana 3 and CRON - phpStatic map API that supports HTTPS requests and is free - httpsFunction to put the entire database table in an array - phpCreating / compiling .net data class in application - c #Каков эффект в Ruby при инициализации с помощью nil: x = String (nil) - nullAll Articles