I've seen in some other threads that we should be able to use paths with queries in them in the form of from: ? , but this doesn't seem to work for me and I'm not sure if I'm doing it right or if it just doesn't work because the question mark is located where it is.

This is the path to redirect: wordpress/?feed=rss2

I have tried wordpress/?feed=rss2 and wordpress/feed=rss2 and neither redirect works

How can I redirect these wordpress links and feeds?

Comments

dave reid’s picture

Try without the trailing slash (wordpress?feed=rss2). Also, if these paths currently exist and are actually valid wordpress paths, we can't do anything about it.

sansui’s picture

The paths don't exist on this server - they're from an old server. I also have a redirect for just "wordpress" which redirects to "blog". Every redirect that has wordpress in it seems to just redirect to the main "blog" page. Any idea what's happening there?

sansui’s picture

Ah... removing that redirect fixed it and I was able to get the other redirects working. Hrmm.. but now how do I redirect just "wordpress"? ;(

jack.r.abbit’s picture

Ah... I am having the same issue. I have a main page "something.asp" and it has some sub pages "something.asp?tab=1" and "something.asp?tab=2". I set up redirects for all three of them to different URLs but they all redirect to the URL for "something.asp". I'm not sure why it "fails". Perhaps it is matching the first one and quits looking for the one that matches the query string. Is this a bug?

jack.r.abbit’s picture

Category: support » bug

I believe the logic in path_redirect_compare_array() is a little backwards. The function accepts two parameters: $match and $haystack where $match is the query string from the database and $haystack is the query string from the original URL.

function path_redirect_compare_array($match, $haystack) {
  foreach ($match as $key => $value) {
    if (!array_key_exists($key, $haystack)) {
      return FALSE;
    }
    elseif (is_array($value)) {
      if (!is_array($haystack[$key])) {
        return FALSE;
      }
      elseif (!path_redirect_compare_array($value, $haystack[$key])) {
        return FALSE;
      }
    }
    elseif ($value != $haystack[$key]) {
      return FALSE;
    }
  }
  return TRUE;
}

So path_redirect_compare_array() is called repeatedly with the results of $redirects = path_redirect_load_multiple(). But if $redirects contains a redirect without a query string then when path_redirect_compare_array() gets called, it gets passed an empty $match array which will never get looped through in the function so it will return a TRUE... even if another redirect had matching query parameter. I think if you switch the two arrays (loop through $haystack and compare it to $match) then the logic will work out.

jack.r.abbit’s picture

@Sansui ~ Since the redirects are evaluated in the order they are entered, you can always enter the one without the "?" last. It will be at the bottom of the list so the others have a chance to get picked first. Not ideal but it works.

sansui’s picture

Thanks for the tip jack :) I think by serendipity it eventually ended up that way in my configuration, as I noticed the main redirect began working (probably after deleting and readding it at some point, putting it at the end of the redirects).

I'm sure there are others that will benefit from seeing that tip posted too :D

dave reid’s picture

Assigned: Unassigned » dave reid

Ok looking into this not being able to handle this properly...

dave reid’s picture

Version: 6.x-1.0-beta7 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new9.78 KB

Alrighty, here's the backport of the improvements I've done to selecting a redirect by source from the Redirect module for Drupal 7 which should fix this bug. Even added tests that with the bug fix part reverted, confirms I get 1 error. Tested and patched against 6.x-1.x-dev.

dave reid’s picture

Revised patch after testing changes were committed.

dave reid’s picture

Status: Needs review » Fixed

Ok I feel good about #10 so I committed it to CVS. http://drupal.org/cvs?commit=457704

Would be great if everyone having this problem could re-check the 6.x-1.x-dev version in about 12 hours and re-confirm that it's fixed for you as well.

Status: Fixed » Closed (fixed)

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