Hi,

I would like to redirect 'node/38' to 'node/58'. I use hook_menu() but it only works when logged in as 'user/1'. If I logged off, it always redirects 'node/38' to front page.

Here is my code:

function redirectpage_menu() {
	$items = array();

	$items['node/38'] = array(
		'title' => 'Redirecting page',
		'access arguments' => FALSE,
		'page callback' => 'redirected_page',
		'type' => MENU_CALLBACK,
	);
	return $items;
}

function redirected_page() {
	drupal_goto($path = 'node/58');
}

Any idea?

Thanks.

hc.

Comments

taslett’s picture

You probably only need to have an 'access callback' return TRUE in your hook_menu.
Otherwise you could use: hook_url_inbound_alter

Jaypan’s picture

Change this:

'access arguments' => FALSE,

To this:

'access callback' => TRUE,
chanjay’s picture

Thank you. It works!

hc.

Liam Morland’s picture

No need for your own callback function:

function redirectpage_menu() {
	$items = array();
	$items['node/38'] = array(
		'title' => 'Redirecting page',
		'access callback' => TRUE,
		'page callback' => 'drupal_goto',
		'page arguments' => array('node/58'),
		'type' => MENU_CALLBACK,
	);
	return $items;
}