I'm new to SEO and not sure how exactly google crawler works
If I use the following format for URL:
example.com/category/id/name
The content of the page is loaded by only the id part, the other parts of URL are for SEO.
No matter what I put in category or name, the page will still load as far as the id is correct. How will this affect the googlebot's crawling? I only want it to index one id with it's correct category and name.
Does it help if I put one url in sitemap.xml for every id?
When I fetch data based on id, I can find the correct category and name. If I find they are not correct, I can setup a redirect:
if(url !== "example.com/incorrect-category/id/incorrect-name){
<script> window.location = "example.com/correct-category/id/correct-name" </script>
}
Will that help prevent googlebot crawling pages with the incorrect category and name? Is that the right way to do it?