Root Relative URLs
Using Root Relative With Yoast Sitemaps (2 posts)

  1. abaisley
    Posted 3 years ago #

    WordPress Version: 3.5.2
    Yoast Version: 1.4.13
    Root Relative URLs Version: 2.3


    I'm using Root Relative for my site, http://www.shopp.ly. Mostly for staging purposes (I have a separate staging site, a script on AWS that hits the staging site looking for changes and pushes those changes to CloudFront). Anyway, no real problems with it and happy with the plugin except one nagging issue...

    I can't seem to get absolute URLs in the XML sitemaps generated by the Yoast WordPress SEO plugin. I understand that Google's inability to read these URLs is their problem, not this plugin's and I've read other posts here about this issue, but I can't seem to get any of the fixes to work.

    You can see the sitemap here: http://www.shopp.ly/sitemap_index.xml

    I've tried a few things. I've tried adding the following to the blacklist under Settings>General:


    That didn't seem to do anything, so I tried adding:


    That didn't seem to do anything either.

    I tried another possible fix that I read here: http://wordpress.org/support/topic/xml-sitemaps-issue-with-root-relative-urls-plugin?replies=1

    I added the following code to line 556 of the file class-sitemaps.php AND tried replacing the block of text starting on 556. Neither seemed to do anything.

    if (strpos($url['loc'], "http") === 0 ) {
    $output .= "\t\t<loc>" . $url['loc'] . "</loc>\n";
    } else {
    $output .= "\t\t<loc>http://" . $_SERVER['HTTP_HOST'] . $url['loc'] . "</loc>\n";

    But I'm not a developer, so I don't know what this would actually do.

    Anyone have any idea how I can get this working?


  2. John Huebner
    Posted 2 years ago #

    Here's a hack that'll make this work with Yoast, but please note that this will only work if the only files with .xml extensions are your sitemap files.

    At the very top of plugin (sb_root_relative_urls.php) find this:

    add_action('plugins_loaded', array('MP_WP_Root_Relative_URLS', 'init'), 1);

    Change it to:

    if (!preg_match('/\.xml$/', $_SERVER['REQUEST_URI'])) {
      add_action('plugins_loaded', array('MP_WP_Root_Relative_URLS', 'init'), 1);

    Basically it's disabling the plugin if the requested URL ends with .xml

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Root Relative URLs
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic