Skip to content

🐛 Force root URL to home_url() for correct route URL generation#507

Merged
retlehs merged 1 commit into
mainfrom
fix/route-url-generation
Mar 8, 2026
Merged

🐛 Force root URL to home_url() for correct route URL generation#507
retlehs merged 1 commit into
mainfrom
fix/route-url-generation

Conversation

@retlehs
Copy link
Copy Markdown
Member

@retlehs retlehs commented Mar 8, 2026

Summary

  • Forces URL::forceRootUrl(home_url()) during HTTP boot so route() generates correct URLs regardless of the PHP entry point
  • Without this, requests handled by admin-post.php, admin-ajax.php, wp-cron.php, etc. cause Symfony's Request::prepareBaseUrl() to derive the base path from SCRIPT_NAME, resulting in URLs like http://example.com/wp/wp-admin/admin-post.php/my-route
  • Reproduced and verified the fix with admin-post.php, admin-ajax.php, and wp-cron.php

Closes #400

🤖 Generated with Claude Code

Closes #400

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@retlehs retlehs self-assigned this Mar 8, 2026
@retlehs retlehs merged commit de4609e into main Mar 8, 2026
3 checks passed
@retlehs retlehs deleted the fix/route-url-generation branch March 8, 2026 22:22
@redalpha01
Copy link
Copy Markdown

This one seems to cause issues when using wpml and wanting to show routes from multiple locales

If I'm in /fr and want to show a /en link, I don't want it to be /fr/en

@retlehs
Copy link
Copy Markdown
Member Author

retlehs commented Apr 29, 2026

Please open a new issue with reproduction steps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

route() returns incorrect URLs when request is not handled by index.php

2 participants