custom php cant redirect
freestyler - February 1, 2009 - 21:53
| Project: | CustomError |
| Version: | 6.x-1.0 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I'm trying to make this custom 403 code work
<?php
global $user;
global $_domain;
$path = urldecode(str_replace('destination=', '', drupal_get_destination()));
$path_bits = explode("/", $path);
if ($path_bits[0] == 'node' && is_numeric($path_bits[1]) && !$path_bits[2]) {
$result = db_query("SELECT * FROM {node_access} na WHERE nid = %d AND realm = 'domain_id' AND grant_view = 1", $path_bits[1]);
$domain_grants = array();
while ($domain_grant = db_fetch_array($result)) {
$domain_grants[] = $domain_grant;
}
if (count($domain_grants) >= 1 && $domain_grants[0]['gid'] != $_domain['domain_id']){
$good_domain = domain_lookup($domain_grants[0]['gid']);
drupal_goto($good_domain['path'] . $path_bits[0] .'/'. $path_bits[1]);
}
}
?>Everything is ok, except the drupal_goto function: it causes an infinite redirect loop. Arguments are ok.
Anyone know what I'm doing wrong? Does the drupal_goto function work on a custom 403 error?
PS: Code above was posted on http://drupal.org/node/268537#comment-977130

#1
This has nothing to do with the customerror module. It is a redirect issue.
There is nothing against using drupal_goto() anywhere. Try printing the path that you are trying to redirect to, and see if it gives you any clue.
You probably have the global redirect module, or an .htaccess rule that is causing this.