ITADN

Figure out best way to redirect old comment URLs

#178Closedgeerlingguy 创建于 2026-01-04
migration
G
geerlingguycommented
I'm seeing a fairly substantial number of 404s to paths like `/comment/34297`, which was a comment on the node https://www.jeffgeerling.com/blog/2024/testing-new-raspberry-pi-5-cases-7-79/ <img width="1289" height="768" alt="Image" src="https://github.com/user-attachments/assets/66adf838-d45c-4d4c-bc0d-eeb4f9d54dfa" /> Therefore, I'd like to maybe have a script that goes in and adds aliases for many of these comment URLs to the nodes they were on, so people at least get to the content they were looking for (and 404 logs get a bit less /comment heavy!). A query to grab the nid and title from the Drupal DB: ``` SELECT node.nid, node_data.title FROM node LEFT JOIN comment_field_data comment ON comment.entity_id = node.nid LEFT JOIN node_field_data node_data ON node_data.nid = node.nid WHERE comment.cid = '34297'; ``` Maybe I could write a script (assuming the Drupal site is accessible at http://localhost/) that visits each of the `/comment/[cid]` paths and grabs the URL. Then finds the file inside the Hugo content repo and adds an alias to the node if it doesn't exist? I definitely don't want to do it for _all_ comments, because there are 14,777 comments on the site, and that's just a lotta redirects :P
关闭于 2026-01-17 1 条评论