My drupal website is indexed in Google and I found a link to http://mysite.com/node/345%3Fpage%3D1?page=2 while searching

When I click it it shows content of http://mysite.com/node/345?page=2

This may be due to some site or sitemap pointing to the url http://mysite.com/node/345%3Fpage%3D1?page=2. And Google indexing it.

But in drupal http://mysite.com/node/345%3Fpage%3D1?page=2 must show a page not found!

Any solution?

The Question CLEARLY:

why the url http://mysite.com/node/345%3Fpage%3D1 showing the content of http://mysite.com/node/345 instead of throwing an "not found" error?

Drupal is not considering "345%3Fpage%3D1" as the node id

  • First you need to enable clean URl and then Re-Index your XML sitemap and also you need to block the paginated pages in robot.txt file to avoid duplicate content problems. Please rephrase you question currently hard to understand your question.
    – Bala
    Apr 26, 2014 at 9:37
  • Hi Bala, I have enabled clear URLs. The sitemap does not contain paging. I want pagination as my site is a forum. I just want the mysite.com/node/345%3Fpage%3D1 page to show an not found page. I thinks drupal should read "345%3Fpage%3D1" as the node id. Apr 26, 2014 at 10:07
  • See the first sentence "My drupal website is indexed in Google and I found a link to mysite.com/node/345%3Fpage%3D1?page=2 while searching". You have not read the question carefully! Apr 27, 2014 at 14:01

2 Answers 2


Using URL encoding to append a query string to an URL doesn't change the address of the URL. %3F, is just a slighly obscure way to write "?", and %3D is just a slighly obscure way to write "=".

So the URL:


is equivalent to this URL:


Wikipedia says:

Reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not.

So what happens is this: When that URL (http://mysite.com/node/345%3Fpage%3D1) is requested, page 1 of http://mysite.com/node/345 is actually requested. If node/345 exists on your site, Drupal will show it. If there are no pages defined, it doesn't matter, because Drupal by default ignores anything in the query string part of the URL that it does not recognise.

You wrote:

Drupal is not considering 345%3Fpage%3D1 as the node id.

That is the correct behaviour. The node id is "345". What follows is what is known as a query string. A query string starts with either ? or %3F. Those two ways of starting a query string are semantically equivalent.

This is how all Drupal sites works, if a non-existing pagination is specified in the query-string part of the URL, it is just ignored. Take a look of the following three URLs:

Notice that they all go to node/2182323 on Drupal.org. That is because there is no page 42 for that node (there are actually no extra pages for that node).

As far as I know, there is no simple way to change this default behaviour to return a "Page not found" (404) response when there is no match for the query string part of the URL.

  • But Free Radical, mysite.com/node/345%3Fpage%3D3 is showing mysite.com/node/345 Apr 26, 2014 at 12:56
  • @BuntuLinux, yes - and that is Drupal's default behaviour. Do you want to change this so that Drupal returns 404 if the query string does not match a query on the site? Apr 26, 2014 at 13:21
  • Yes Free Radical! That is what I want! Apr 26, 2014 at 13:35
  • I just found that mysite.com/node/32dafsdfasdfafasdf shows the content of mysite.com/node/32 Apr 27, 2014 at 5:30
  • @BuntuLinux wrote is response to whether it was about returning a 404 status code: "That is what I want!" However, as is evident from yiur self-aswer, this is not what you want. Apr 27, 2014 at 9:59

Finally I think I found a solution:

Please correct me if I am wrong!

Now its adding a canonical meta tag for nodes and for forums together with the page variable.

in my template.php I changed bartik_preprocess_node function and added bartik_preprocess_forums function.

function bartik_preprocess_node(&$variables) {
  //start added by me
    $uri = entity_uri('node', $variables['node']);
    if($GLOBALS['pager_page_array'][0] != 0){
        $uri['options']['query']['page'] = $GLOBALS['pager_page_array'][0];
    // Set the node path as the canonical URL to prevent duplicate content.
    drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
    // Set the non-aliased path as a default shortlink.
    drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
  //end added by me

  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';

//added by me
function bartik_preprocess_forums(&$variables) {
    $uri = array();
    $uri['path'] = 'forum';
    if($variables['tid'] != 0){
        $uri['path'] = 'forum/'.$variables['tid'];
    $uri['options'] = array();
    if(isset($GLOBALS['pager_page_array']) && $GLOBALS['pager_page_array'][0] != 0){
        $uri['options']['query']['page'] = $GLOBALS['pager_page_array'][0];

    drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);

Also I removed the lines that adds the canonical meta tag in the node.module (But may not be a good idea to alter core modules).

Therefor: mysite.com/node/345%3Fpage%3D3 would have a canonical as

<link rel="canonical" href="/node/345">

and mysite.com/node/345%3Fpage%3D3?page=2 would have a canonical as

<link rel="canonical" href="/node/345?page=2">

Similarly for the forum topic pages.

  • 1
    This is not an answer to your question, which was: "why the url mysite.com/node/345%3Fpage%3D1 showing the content of mysite.com/node/345 instead of throwing an 'not found' error?" There is not even a hint in your question that you were looking a cure for duplicated content for SEO purposes. Anyway, if that is what you wanted, you should be able to use the Metatag module to add canonical metatags. Apr 27, 2014 at 9:57
  • 1
    Hey, The first sentence states that this is a problem with Google. So you should have understood that! If there is no solution, you should have suggested an alternative one like this. Apr 27, 2014 at 13:58

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