{"id":6843040,"date":"2015-12-12T11:08:41","date_gmt":"2015-12-12T11:08:41","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/please-use-relative-urls-in-the-wordpress-database\/"},"modified":"2016-08-30T21:15:40","modified_gmt":"2016-08-30T21:15:40","slug":"please-use-relative-urls-in-the-wordpress-database","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/please-use-relative-urls-in-the-wordpress-database\/","title":{"rendered":"Please use relative URLs in the WordPress database"},"content":{"rendered":"<p>I know, I know, the request for relative URLs in WordPress has been made many times and then knocked back every time by the WP devs, but bear with me.<\/p>\n<p>What I&#8217;m asking for isn&#8217;t the removal of absolute URLs from the HTML generated by WordPress &#8211; this is the &#8220;defence&#8221; used by WP devs each time. Absolute URLs can still be output, but have them constructed by the use of $_SERVER variables that PHP provides.<\/p>\n<p>What I want changed is that the *database* only stores relative URLs when referring to content on the site. Even the top-level URL doesn&#8217;t need to be stored (again, $_SERVER variables can be used) &#8211; nothing in the WP DB needs to ever mention an absolute URL for content on the site itself.<\/p>\n<p>If it was easy to substitute absolute URLs in the database when say going from dev -&gt; UAT -&gt; live, then it wouldn&#8217;t be such an issue, but you can&#8217;t simply mysqldum\/sed\/mysql for such a move because serialised data prevents it. Instead, I have to tediously use a special third-party tool such as:<\/p>\n<p>https:\/\/interconnectit.com\/products\/search-and-replace-for-wordpress-databases\/<\/p>\n<p>Wouldn&#8217;t it be great if I never had to do any search\/replace (sed or the tool above) at all though to move the WP DB to another URL? It&#8217;s by far the most frustrating thing during develoment at the moment (or even if you&#8217;re just converting a site from http to https) and I can&#8217;t believe WP devs just keep ignoring this request over the space of many years.<\/p>\n<p>Remember &#8211; absolute URLs will remain in the HTML (constructed from $_SERVER variables plus a relative URL from the DB) output by WordPress, which negates the only reason WP devs refuse to implement this. It&#8217;s the *database* that will change to using relative URLs, not the HTML that&#8217;s output.<\/p>\n","protected":false},"template":"","class_list":["post-6843040","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6843040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6843040\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6843040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}