WordPress.org

Ready to get started?Download WordPress

Forums

Google XML Sitemaps
How do you remove trailing slashes from file? (2 posts)

  1. jhansensd
    Member
    Posted 3 years ago #

    Hello, I am pissed because I noticed the XMl Sitemaps plug in appends a trailing slash to every single file, including http://www.home.com/. My web server, hostgator, does a 301 redirect from http://www.home.com/ to http://www.home.com. But the fact the sitemap includes the / leads me to believe something is going to get screwed.

    Another issue I noticed is that wordpress seems to append trailing slashes onto everything.

    Question 1) How To Remove Traling Slashes from XML Sitemap
    Question 2) How to Remove Trailing Slahes from all wordpress pages.
    Question 3) Does google determine the name of your page by the sitemap or by the webserver? I don't see how google could put in my http://www.home.com/ for my home page because that is 301 REDIRECTED! How is this possible?

    http://wordpress.org/extend/plugins/google-sitemap-generator/

  2. nootron
    Member
    Posted 3 years ago #

    you're pissed? That's quite a way to start a post asking for help :P

    Nonetheless, I will help :)

    open sitemap-core.php.

    Go to line 284.

    You see this:

    $r.= "\t\t<loc>" . $this->EscapeXML($this->_url) . "</loc>\n";

    Change this one line to the following two lines:

    $hack_url = substr($this->_url,-1,1) == '/' ? substr($this->_url,0,-1) : $this->_url;
    $r.= "\t\t<loc>" . $this->EscapeXML( $hack_url ) . "</loc>\n";

    Hopefully this solution works and you won't be "pissed" at me too. ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic