WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. abaisley
    Member
    Posted 11 months ago #

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

    Hi,

    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:

    /sitemap_index.xml
    /post-sitemap.xml
    /page-sitemap.xml
    /category-sitemap.xml
    /author-sitemap.xml

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

    http://www.shopp.ly/sitemap_index.xml
    http://www.shopp.ly/post-sitemap.xml
    http://www.shopp.ly/page-sitemap.xml
    http://www.shopp.ly/category-sitemap.xml
    http://www.shopp.ly/author-sitemap.xml

    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?

    http://wordpress.org/plugins/root-relative-urls/

  2. Hube2
    Member
    Posted 3 months 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

Reply

You must log in to post.

About this Plugin

About this Topic