[wp-trac] [WordPress Trac] #17048: URLs delivered to the browser should be root-relative

WordPress Trac noreply at wordpress.org
Sat Oct 19 21:57:14 UTC 2024


#17048: URLs delivered to the browser should be root-relative
-----------------------------+-------------------------
 Reporter:  dmole            |       Owner:  edwardw
     Type:  feature request  |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  General          |     Version:  3.1
 Severity:  normal           |  Resolution:  maybelater
 Keywords:  close            |     Focuses:
-----------------------------+-------------------------

Comment (by nickchomey):

 I just thought I'd chime in here with my experience with this. A few
 months ago, I spent A LOT of time trying to figure out a way to use
 relative links in WordPress. I was convinced that I'd solve this issue,
 once and for all.

 I quickly determined that it would be impossible to do this via any sort
 of MU plugin, as various approaches tried.

 What I thought would work would be doing url rewrites in a proxy in front
 of WordPress. I use the ''fantastic'' DDEV tool for local development,
 which uses Traefik for routing between different locally-hosted projects.
 I figured out how to use some traefik middlewares with some very fancy
 regexes to rewrite the response body and headers, and it was working
 great!

 Then, I started noticing edge cases - Gutenberg sending full URLs when
 submitting posts with internal links, issues with Media, etc...

 I set up the middlewares to rewrite request headers and body as well, and
 got past those edge cases. Then other issues came up.

 Ultimately, I strongly advise people not to go down this path. You'll be
 playing whack-a-mole forever.

 Just accept that paths will always be absolute, and use the forbidden
 Better Search Replace plugin or Go Search Replace
 (https://github.com/Automattic/go-search-replace) to rewrite your URLs
 when moving sites around.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/17048#comment:69>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list