The subject describes it pretty well. I recently installed Drupal on a domain and took out all of the old (Manually created) .htm, .html and .php files, and want all of the old URLs (In google indexes) to be forwarded to the front page en masse (As in, not having to do each one manually because there are a ton).

Any ideas?

Comments

lomz’s picture

Sykoi’s picture

Sadly that won't work, most URLs are combined shortened words and after installing it, not a single old-url I tested returned any results.

lomz’s picture

If you go to /admin/settings/error-reporting you can change the errorpage.

-----------------
Vindstille.net | Gravide studenter mer friske enn andre gravide?

sumitshekhawat7331’s picture

this technique... i have used for access denied error hope it will works for you after some changes

1) Create a node of type page. You must have the PHP input filter enabled.

2) In body section insert

       <?php
	global $user;
	if ($user->uid) { // this user is already logged in
	print "Access Denied: You do not have access to this page.";
	} else {
	drupal_set_message("Access Denied: Please Login");
	$dest = drupal_get_destination();
	drupal_goto('user/login', $dest); // this remembers where the user is coming from
	}
	?>

3) Submit the node (you should see the "Access Denied: You do not have access to this page." message

4) Remember this node's ID number

5) Goto admin/settings

6) # In the section about alternate 403 error pages, insert "node/XXXX" where XXX is your node's ID number

7) Test it

8) If you would prefer, you can use this alternate code to force a redirect to the login page after 10 seconds (instead of immediately).

9) <?php
	global $user;
	if ($user->uid) { // this user is already logged in
	print "Access Denied: You do not have access to this page.";
	} else {
	$dest = drupal_get_destination();
	$url = "http://www.youdomain.com/user/login?destination=$dest"
	drupal_set_html_head('<meta http-equiv="refresh" content="10;URL=' . $url . '">');
	}
	?>

10) http://drupal.org/node/69007#comment-637218 (infinite loop error)

shevot’s picture

I had a lot of problems with Google linking to old pages that I had done away with, the page not found errors were driving traffic away. The solution that worked for me is similar to the original solution but the php code is different. I don't even give the enduser an error message to begin with, I just redirect right off the bat. These are the steps that I took.

  • Create a new page that is published but not promoted to front page. You can name the page anything you want, it is irrelevant, but I named it "Wrong Page".
  • Enable php for the page and then add the following php code:
    <?php
    header( 'Location: yourURL' ) ;
    ?>

    Replace yourURL with your homepage URL or the page you want redirected to. If you are using automatic aliasing make sure it is disabled.

  • After you save the page, if it worked you will be redirected to your homepage.
  • Go to your content management (admin/content/node), find the newly created node and choose "edit". This is how you will find out the node number, because the page redirects otherwise. Looking in the url, you will find "node/xxx" xxx would be your node number.
  • Go to your admin page that handles error page redirects (admin/settings/error-reporting). Put the node number (node/xxx) of the page you created into the space for the default 'page not found' or 'access denied' urls, whichever you want or both.

    This will redirect the error pages to the homepage. I choose to also redirect the access denied page because I figured the the "access denied" message might tempt some people to snoop or attempt to hack.

    Hope this works

  • christopherareed’s picture

    Your solution took me 30 seconds, thank you.

    acoburn4’s picture

    Hi Shevot,

    Your solution worked like a charm. I am using the subdomain module on my drupal install, and wanted to redirect people back to the subdomain's homepage if they were trying to access a page not found. I modified one thing on your provided code, and now it's flexible enough to work with subdomains:

    header( 'Location: http://' . ($_SERVER['HTTP_HOST']));
    

    Hope this helps someone else out as well!

    bigga’s picture

    Super simple. Awesome!