Skip to main content
added 100 characters in body
Source Link
Jimajamma
  • 17.1k
  • 1
  • 28
  • 35

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}

You might also want/need to throw in a weight of -1 to make sure your module runs early by putting:

function yourmodule_install() {
  db_query('UPDATE {system} SET weight = -1 WHERE name = "yourmodule"');
}

in yourmodule.install but a quick look just now shows globalredirect's weight at the default of 0 so this may be unneeded.

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}

You might also want/need to throw in a weight of -1 to make sure your module runs early by putting:

function yourmodule_install() {
  db_query('UPDATE {system} SET weight = -1 WHERE name = "yourmodule"');
}

in yourmodule.install.

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}

You might also want/need to throw in a weight of -1 to make sure your module runs early by putting:

function yourmodule_install() {
  db_query('UPDATE {system} SET weight = -1 WHERE name = "yourmodule"');
}

in yourmodule.install but a quick look just now shows globalredirect's weight at the default of 0 so this may be unneeded.

added 253 characters in body
Source Link
Jimajamma
  • 17.1k
  • 1
  • 28
  • 35

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}

You might also want/need to throw in a weight of -1 to make sure your module runs early by putting:

function yourmodule_install() {
  db_query('UPDATE {system} SET weight = -1 WHERE name = "yourmodule"');
}

in yourmodule.install.

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}

You might also want/need to throw in a weight of -1 to make sure your module runs early by putting:

function yourmodule_install() {
  db_query('UPDATE {system} SET weight = -1 WHERE name = "yourmodule"');
}

in yourmodule.install.

Source Link
Jimajamma
  • 17.1k
  • 1
  • 28
  • 35

If you want to do this yourself, quick and dirty, it would be something like this:

function yourmodule_init() {

  $foo=drupal_get_path_alias($_GET['q']);
  $bar=explode('/',$foo);

  if ($bar[0]=='this-string-to-redirect') {
    $bar[0]='redirect-me-here';
  }

  $baz=implode('/',$bar);

  drupal_goto($baz);

}