I saw a few questions like this around (like this one), but none of them tackle the problem specifically.
So Google is now supporting SPAs and most web browsers do HTML5 pushState.
My AngularJS (but could be any JS thing) website is using the URL to determine an API route. It then performs the API call and then renders the content accordingly.
However, right now Google tagged this site as "being hacked" since EVERY URL returns an HTTP 200 status code (example.com/get-free-viagra included). Fair, but how do I return a 404? Or at least inform Google that this is a not-found page? They don't seem to be providing that information and I'm seriously worried about SEO.
A few ideas came to my mind:
- Deprecate my current setup (I'm using AWS S3 to host the static website), and use an expressJS box instead, with a middleware that would perform the API call and return the 404 if needed. However, I don't like the approach since it will harm performance (two API calls per frontend request).
- Use
window.location
to redirect to a proper 404 page. However, I'm not sure if Google will follow it and it's already discouraged to change the URL. - Use
rel="nofollow"
on not found pages, but I don't feel this is enough.
I'm now frustratingly leaning towards the first option right now.