Just wanted to document this in case others run into this problem. Not sure if this is worth added to overall module documentation, but, I guess, that's up to the maintainer.

I just spent an hour trying to figure out why a redirect was not working.
Instead of successfully redirecting, I was getting the "from:" URL with a trailing +

What's happening - W3 URL encoding standards say that a space can be encoded as a %20 (which I was familiar with, and is typical for PHP and ASP) or as a +, if it is submitted directly to a web browser. http://www.w3schools.com/TAGS/ref_urlencode.asp

So, if your "from:" URL contains a trailing space, it will:
1. Try to redirect a page that doesn't exist (which will fail)
2. Fail to redirect to the page that you expect (as the redirect is being applied to the wrong URL)

This can be an issue in other parts of Drupal as well (like the block visibility settings), so, remember to look for and remove trailing spaces from URLs!

Comments

nicholasThompson’s picture

Title: Trailing spaces break redirect » Trim trailing spaces
Version: 5.x-1.5 » 7.x-1.x-dev
Component: Documentation » Code
Assigned: Unassigned » nicholasThompson
Status: Active » Needs work

Nice find. I'll add this to the next release... It'll be a simple trim() around the $_GET['q']

rp7’s picture

Issue summary: View changes

Unsure if I'm understanding this issue correctly - but is it the intention to redirect URL's with a trailing whitespace (%20) to the same URL without the trailing whitespace? If so, I'm all for this - even willing to write a patch.

The reason I need this: my installation is using Boost, and I see that it's creating seperate entries for URL's with and without trailing whitespace. Might be the same with other caching mechanisms, haven't tested this any further.