Do search engines crawl links with query strings?

The question:

If I were to have a url like https://example.com/books, that contained several links to urls such as:

https://example.com/books?id=foo

https://example.com/books?id=bar

https://example.com/books?id=baz

Would search engines crawl and index the content returned by these URLs? If not, what would happen if I were to use a rewrite rule in my .htaccess file to rewrite pretty urls to ugly ones with query strings:

https://example.com/books/foo -> https://example.com/books?id=foo

https://example.com/books/bar -> https://example.com/books?id=bar

https://example.com/books/baz -> https://example.com/books?id=baz

Would there be any difference/preference? Or would a search engine crawl both?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Yes. Query strings are part of the URL and as such are viewed as directing the robots to different pages.

There may be a preference to using a path because then Google can test the parent. So if you have:

https://example.com/books/baz

Google will eventually test

https://example.com/books

on its own (it could be that they don’t do it anymore though, but I’m sure I read that somewhere on a page owned by Google.)

One thing for sure, if you allow both, make sure to add a canonical meta tag with your preferred URL otherwise you could get penalized because of the duplication.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment