2

It's quite common, although not always recommended, to see something in the form of http://my.site.com/index.php?page=welcome"or simply http://my.site.com?page=welcome. The script (index.php in this case) will then get a "page" item equal to "welcome".

If there are several of these in links within a page, will Google and other search engines index each as a separate page, or will it ignore the "query" part of the url? Consider this simplified example:

<?php // Our index.php - Simple multi-view page ?>
<a href="index.php?page=welcome">Welcome Page</a>
<a href="index.php?page=about">About Page</a>
<a href="index.php?page=contact">Contact Page</a>
<?php
    if(!isset($_GET["page"])) $_GET["page"]="welcome";
    switch( $_GET["page"] ) {
      case "about": echo '<p>This is the About page</p>'; break
      case "about": echo '<p>This is the Contact page</p>'; break
      default: echo '<p>This is the Welcome page</p>'; break

    }
?>

My question here is when Google crawls this page, will it see each of the three pages we link to as separate links, or will it only index a single page (index.php) and ignore everything after the ??

  • 1
    I do something like this but not in PHP. Each will be seen as another page. It will not confuse the search engine. Nor do I have duplicate content issues. However, if at all possible, if you can find a way to use URI paths such as /welcome, /about, /contact, you will be far better off. I am finding it difficult going from long standing pages such as/?=about to /about because of links. It is easy enough to use a regex to convert /about to /?=about. Sheer volume means having to be disciplined in how I/you use parameters. Cheers!! – closetnoc Aug 20 '16 at 0:27
  • I have done this before using apache's REWRITE - you may want to look into that. The way I'm using the query string is: (1) Split querystring by &s into an array, (2) look at the first element of the array, (3) if it doesn't contain an = then it's used as a virtual page name. This has the advantage that there is no = so I can literally take a link that says "?about" and translate it to "/about" or vice versa. – SteJ Aug 20 '16 at 0:35
  • I can do it, I just have to be disciplined. I am totally deleting an entire site so the change should be easy to do. The only caveat I have is the site is so huge! Most of the pages will go away, so in my system, I can return a proper 404 for most of the pages and just let the few legacy pages remain. I am not too worried about links, I just have to think through the process. For now, the sucky site will largely remain while I work on the new content. That will take months. As well, I do have a development server to test theories on before moving it over wholesale. Cheers!! – closetnoc Aug 20 '16 at 0:41
2

Querystrings are counted as part of a URL and variations will be considered unique URLs. So Google will see them as different pages. This also means, in your case, that you will have duplicate content issues and will need to use canonical URLs to specify which URL Google should consider the primary URL which is what will be shown in their search results.

  • Thank you - noted regarding the duplicate content issues, although this was a much simplified example for illustration purposes only and as such doesn't effect my use case. – SteJ Aug 19 '16 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.