Trevor
Trevor

Reputation: 2457

Trying to add a sitemap on aws amplify

I'm running my frontend off of AWS Amplify and I can't figure out how to get the sitemap to appear. It just keeps on saying error 404 on aws amplify. but on localhost it goes straight to it. robots.txt works fine on both though.

Here are my AWS Amplify settings. And if it helps, I'm using React

[
    {
        "source": "https://www.my-domain.com",
        "target": "https://my-domain.com",
        "status": "301",
        "condition": null
    },
    {
        "source": "/<*>",
        "target": "/index.html",
        "status": "404",
        "condition": null
    },
    {
        "source": "</^((?!\\.(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|xml)$).)*$/>",
        "target": "/index.html",
        "status": "200",
        "condition": null
    },
    {
        "source": "/sitemap.xml",
        "target": "/sitemap.xml",
        "status": "200",
        "condition": null
    }
]

Here's also a screenshot enter image description here

Anybody know what might be the cause for it going to 404? I've tried putting sitemap above, below and removing it. Also adding/removing xml from the third setting.

Upvotes: 0

Views: 1911

Answers (2)

P&#229;l
P&#229;l

Reputation: 21

One solution is to change the rewrites and redirect settings in AWS Amplify to allow file types ending in .XML to be returned and not forwarded to the root URL (/).

Upvotes: 1

Trevor
Trevor

Reputation: 2457

Solved it.

  1. I removed /sitemap.xml.
  2. Then made sure sitemap looked like sitemap.xml exactly.
  3. Then emptied my cache and did a hard reload.

Even though AWS was updating the URL. It had cached results.

Upvotes: 0

Related Questions