Need with XML htaccess rewrite

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lakerslive
    Confirmed User
    • Aug 2012
    • 929

    #1

    Need with XML htaccess rewrite

    Hi guys

    so my sitemap is currently under domain.com/sitemap/

    I need for it to be domain.com/sitemap.xml

    How should htaccess look?

    Currently it looks like
    RewriteEngine On
    RewriteRule ^sitemap.xml/?$ index.php


    ty
  • just a punk
    So fuckin' bored
    • Jun 2003
    • 32385

    #2
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^sitemap.*$ https://domain.com/sitemap.xml [R=301,L]
    Obey the Cowgod

    Comment

    • lakerslive
      Confirmed User
      • Aug 2012
      • 929

      #3
      Thank you. So now, i'm wondering if this is bad SEO redirect?????

      So i had another dev do a redirect for me

      before >
      domain.com/sitemap/ was the url

      after >
      domain.com/sitemap.xml << developer made this link possible via htacess

      PROBLEM #1
      domain.com/sitemap/ << if you visit this page it still EXISTS

      so developer made ANOTHER redirection via .htaccess
      domain.com/sitemap/ to domain.com/sitemap.xml

      PROBLEM #2
      domain.com/sitemap/ KINDA exists... but HOW?

      step1:
      go to yahoo.com

      step2
      go to to domain.com/sitemap/ it will redirect you to domain.com/sitemap.xml BUT if you press "BACK" button on navigation
      it will take you back to "sitemap.xml" when it should be YAHOO.com ?????? so, this bad redirect???????????????????????

      Comment

      • zerovic
        Confirmed User
        • Apr 2010
        • 1114

        #4
        Personally, I love to have my redirects placed as clean as possible. If the sitemap is available on both URLs, you don't have to worry.

        I had to read about sitemap files to make sure my sitemaps are good, but my conclusion is this.. you are on the same domain, you can have as many sitemaps as you want, search engines simply record the URLs you have and that's it.

        Having two sitemaps, /sitemap/ and /sitemap.xml won't hurt you in any way in my opinion...

        What concerns me the most, is migrating from HTTP to HTTPS.. Google says, you don't need to change anything anywhere, set a redirect and you are good to go, as Google will notice the change and simply follow your redirects, however, since I re-added one of my websites as HTTPS, my traffic doubled, and google considers my "old site", the same website, with HTTP, as a bad site for some reason. The site, with HTTP, has thousands of URLs excluded from the search results, while the newly added, even without a sitemap, with HTTPS, is loved by google.

        Also, for some reason.. google will also ignore my robots.txt file here and there. Even if I have my redirect URLs set to /disallow/, there are many keywords ranking directly to sponsor through my URLs.

        It's like, searching for "GFY" and you receive my URL, in the top fckn 5 results, which is like "domain.com/go/gfy", which leads you to gfy.com with my affiliate link lol

        ps. I'm experimenting with lots of new ideas, and this somehow works. Not for long, for sure, but for now, google sends me free traffic on keywords I never even wanted to rank lol
        php, html, jquery, javascript, wordpress - contact me at contact at zerovic.com

        Comment

        • just a punk
          So fuckin' bored
          • Jun 2003
          • 32385

          #5
          Originally posted by zerovic
          Personally, I love to have my redirects placed as clean as possible. If the sitemap is available on both URLs, you don't have to worry.
          Yep. The OP may also put this in his robots.txt:

          Code:
          Sitemap: https://domain.com/sitemap.xml 
          Sitemap: https://domain.com/sitemap/
          User-agent:*
          Disallow
          Obey the Cowgod

          Comment

          • zerovic
            Confirmed User
            • Apr 2010
            • 1114

            #6
            Originally posted by CyberSEO
            Yep. The OP may also put this in his robots.txt:

            Code:
            Sitemap: https://domain.com/sitemap.xml 
            Sitemap: https://domain.com/sitemap/
            User-agent:*
            Disallow
            And there's nothing to worry about in my opinion.
            php, html, jquery, javascript, wordpress - contact me at contact at zerovic.com

            Comment

            • zijlstravideo
              Confirmed User
              • Sep 2013
              • 806

              #7
              Originally posted by zerovic
              Also, for some reason.. google will also ignore my robots.txt file here and there.
              Yeah, seen this happen a few times as well. Even for pages for which it didn't make any sense to get indexed at all, like you've mentioned, outgoing redirect pages and such...

              Adding a php header to these type of pages, fixed it for me:
              header("X-Robots-Tag: noindex, nofollow", true);
              Contact: email

              Comment

              • FansCity
                Confirmed User
                • Jan 2022
                • 34

                #8
                Sometimes I don't understand how it happens

                Comment

                • zijlstravideo
                  Confirmed User
                  • Sep 2013
                  • 806

                  #9
                  Originally posted by lakerslive
                  PROBLEM #1
                  domain.com/sitemap/ << if you visit this page it still EXISTS

                  so developer made ANOTHER redirection via .htaccess
                  domain.com/sitemap/ to domain.com/sitemap.xml

                  PROBLEM #2
                  domain.com/sitemap/ KINDA exists... but HOW?
                  If the old url (/sitemap/index.php) is a real path, then yes, you would also still be able to access it directly at /sitemap or /sitemap/index.php.

                  To prevent this, add something like this at the top of the page at /sitemap/index.php:

                  if ($_SERVER[REQUEST_URI] === '/sitemap/index.php' || $_SERVER[REQUEST_URI] === '/sitemap/')
                  {
                  header("Location: http://$_SERVER[HTTP_HOST]/sitemap.xml",TRUE,301);
                  die();
                  }

                  It simply checks the current path. If the visited url contains "/sitemap/ " or "sitemap/index.php", force a redirect to yourdomain.com/sitemap.xml.
                  Contact: email

                  Comment

                  Working...