HTTP 301 Page moved in Drupal

Scope: Move an old document to a new URL with HTTP 301 Permanent Redirect.

Module used (required if you don’t want to modify an existing page): URL aliases.

  1. Create a new page (or edit an old one). Select “PHP code” in input type.
  2. Fill the url alias box, with the old document path
  3. Insert the following code: <?php
    // Permanent redirection
    header(“HTTP/1.1 301 Moved Permanently”);
    header(“Location: http://www.yoursite.tld/location&#8221;);
    exit();
    ?>
  4. Save.

Note: Obviously you can’t see the page (you’ll be redirected to specified address), but you can edit or delete the page from admin/content/node. As admin, if you try to unpublish the page you’ll be redirected anyway: you have to delete the page to fix it.

See also: http://www.somacon.com/p145.php

Advertisements

One thought on “HTTP 301 Page moved in Drupal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s