Great Module.

I have a Drupal 7 site that is not in the main directory but housed in a subdirectory. The subdirectory is added to the front of the redirect string which means after a user logs in, they are redirected to an invalid url path. Which means they receive a 404 error.

How do I fix this.

Comments

komlenic’s picture

This occurs in the 6.x version also.

chunty’s picture

I have the same problem in 6. I believe the issue is that the drupal function request_uri() includes the base path. I'm not sure if this is the best way but it could be fixed by replacing the line the function r4032login_redirect() which says:

// Check for path prefix and strip it out if its found.
$path = _r4032login_remove_language(request_uri());

with the following lines:

// Remove the base_path so this works when in subdirectories
$path = str_replace(base_path(), '', request_uri());
// Check for path prefix and strip it out if its found.
$path = _r4032login_remove_language($path);

I don't use git so I'm not sure how to submit a patch or of this is the "best" way but I'd be interested to hear from the module author either way.

ermannob’s picture

Status: Active » Needs review

Thanks chunty, you solution works for me.

ermannob’s picture

Status: Needs review » Needs work

Well, that's not a proper solution. It will fail if base_path() returns "/".
A more generic solution would be this:

// Remove the base_path so this works when in subdirectories
$path = request_uri();
$pos = strpos($path, base_path());
if ($pos !== false) {
    $path = substr_replace($path, '', $pos, strlen(base_path()));
}
// Check for path prefix and strip it out if its found.
$path = _r4032login_remove_language($path);
chunty’s picture

Yer I came undone by my own code just last week and did something similar. I just put my code inside:

<?php
if (base_path() == '/') {
}
?>
garphy’s picture

Status: Needs work » Fixed

I think it's fixed in 1.6. $destination is now handled with drupal_get_destination().

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.