Hi, Unless I am not setting this up correctly, all anchors/fragements are being removed when a link is updated. Is there a way to maintain these anchors?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | fragment-persist-on-update-2066007-11.patch | 843 bytes | joecorall |
Hi, Unless I am not setting this up correctly, all anchors/fragements are being removed when a link is updated. Is there a way to maintain these anchors?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | fragment-persist-on-update-2066007-11.patch | 843 bytes | joecorall |
Comments
Comment #1
hass commentedPuhhh... that's in correct.
The module only takes the 301 redirect url and if this does not provide the anchors/fragments it get's removed. I'm not sure if it's correct to maintain the anchors/fragments if they are not in the 301. It may be useful if you change your site structure without changing your content. If we keep the anchors/fragments on automatic updates it will fail later as the anchors/fragments is now also verified since v1.1. This means we could add this as a new feature. Can you share a patch, please?
I'd like to hear some others if this is the way how it should work (design wise) as I'm not sure... what are web browsers doing here with the anchors/fragments?
Comment #2
plinto commentedI'm not sure I understand, so I will explain my situation.
I recently migrated to drupal, but all the links in the pages are the old urls, so basically almost every link on the website is a 301. I want to update all the links with the new drupal generated url. The problem is some links have anchors (and these achors do exist within the linked page) and they are being stripped.
You mention a patch, I would love to able to write one but don't know drupal well enough yet and don't have the skills
Comment #3
hass commentedMainly I need to know what browsers are doing. Fragments a a bit special. If browser will not keep the fragment on redirects I may not implement it in linkchecker, too. Otherwise if they do, we should also keep the fragment in linkchecker, too.
Comment #4
plinto commentedI believe browsers maintain the fragment
Example: If you go to the courses tab on http://www.europe.umuc.edu/undergraduate/bachelors/accounting
All classes have a link with fragment, and all of the links are 301 redirects. If you click one the link is updated and the fragment is maintained
Comment #5
hass commentedPatch attached (untested)
Comment #6
hass commentedAnd now without tabs.
Comment #7
hass commentedAnd now without tabs.
Comment #8
plinto commentedThanks, I will test the patch right away
Comment #9
hass commentedComment #10
hass commentedAny news on your test results?
Comment #11
joecorall commentedI tested the latest patch, and fragments were not being appended to the end of the new URL.
The test was a drush script with the logic from that patch, with an example old URL and new URL:
And the output shows a failure to add the fragment to the end of the new URL:
So I have attached my own patch which has been tested locally to have "#", and everything afterward, persist in the new URL. I'm submitting the patch to be reviewed by the community.
Comment #12
hass commentedComment #13
quadrexdevD7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.
Thanks!