Closed (outdated)
Project:
Redirect
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
8 Jul 2014 at 13:01 UTC
Updated:
20 May 2025 at 19:33 UTC
Jump to comment: Most recent
Comments
Comment #1
pere orgaUsing the dev version, I can't reproduce the problem creating redirects using admin/config/search/redirect/add.
Could you specify the steps to reproduce this issue in a clean Drupal 7 install?
Comment #2
honza pobořil commentedSorry for not mentioned it here, I create redirects by the API function redirect_save().
Comment #3
pere orgaOk I'll have a look
Comment #4
pere orgaI can reproduce the issue. The issue can't be reproduced using the Edit Redirect form because the slash is trimmed after submit, and when a redirect is created without a slash, both paths work.
Apparently the Drupal core's Path module is having the same problem. Aliases created with a trailing slash can't be reached.
I guess we could 'fix' the issue trimming the trailing slash inside redirect_save(), so both paths (with and without slash) work when a redirect with a trailing slash is passed through the function.
Comment #5
dave reidIf you're using the raw API, it's typically the responsibility of the module calling the API to make sure it is passing valid data.
Comment #6
pere orgaBut why the data is not valid? He is trying to add redirect with a trailing slash.
Comment #7
dave reidIt has been a long-standing standard that save API functions do as little processing as possible. If path_save() were to also do this or similar, then I would gladly accept this change for redirect_save() as well. A redirect with a trailing slash on it is not a vaild source path, hence invalid data.
Comment #8
pere orgaI agree that what I proposed is a bad idea, it was more a workaround that could have other implications.
The issue here is that paths ending with a slash can't be inserted independently (without inserting a path without the slash, I mean), which I guess is what the original poster was trying to do. So it's not possible to have a redirect with source path
/source-name/, without having one with the/source-namepath. But this is not an issue ofredirect_save(), it does not work either if I manually insert a path ending with a slash in thesourcecolumn of theredirecttable.Is that a won't fix ticket?
Comment #9
pere orgaApart from that, I still don't see why you consider a path ending with a slash invalid, to me it makes sense to consider it valid.
Comment #10
dave reidOne reason I consider it invalid, is because modules should check to see if a redirect already exists before it can be saved, otherwise it will throw errors on save. Typically this is done using the following:
If an existing redirect is there, but we're trying to save a duplicate redirect with a trailing slash, this will cause errors.
Comment #11
pere orgaMakes sense
Comment #12
honza pobořil commentedOr should not this validation be part of redirect_object_prepare()?
If you think this validation is responsibility of modules using the API, you should document this requirement (to not have slash at start or end of path).
Comment #13
pere orgaYes, that's a good idea. Let's document it.
Comment #14
sonicthoughts commentedI believe this works differently than the global redirect module. I switched and am working with civicrm, which is a seperate application that integrates with drupal on the same server. If I want to redirect domain/test to civicrm/event/info?id=808&reset=1/ it will not work properly. Also, it sometimes expands with a backslash at the end with redirect vs. globalredirect (which I haven't quite figured out yet ...) just another consideration, I'm not sure what the best approach is but wanted to make sure you understood the use case.
Comment #15
wylbur commentedMarking this as Outdated as drupal 7 is EOL.