Use inurl: syntax to search site subdirectories.
The site:
special
syntax is perfect for those situations in which you want to restrict
your search to a certain domain or domain suffix like
âexample.com,â
âwww.example.org,â or
âeduâ: site:edu
.
But it breaks down when youâre trying to search for
a site that exists beneath the main or default site (i.e., in a
subdirectory like /~sam/album/
).
For example, if youâre looking for something below
the main GeoCities site, you canât use
site:
to find all the pages in
http://www.geocities.com/Heartland/Meadows/6485/;
Google will return no results. Enter inurl:
, a
Google special syntax [Section 1.5] for specifying a string to be found in a
resultant URL. That query, then, would work as expected like so:
inurl:www.geocities.com/Heartland/Meadows/6485/
Tip
While the http://
prefix in a URL is summarily
ignored by Google when used with site:
, search
results come up short when including it in a
inurl:
query. Be sure to remove prefixes in any
inurl:
query for the best (read: any) results.
Youâll see that using the inurl:
query instead of the site:
query has two immediate
advantages:
You can also use inurl:
in combination with the
site:
syntax to get information about
subdomains. For example, how many
subdomains does OâReilly.com really have? You
canât get that information via the query
site:oreilly.com
, but neither can you get it just
from the query inurl:"*.oreilly.com"
(because that
query will pick up mirrors and other pages containing the string
oreilly.com that arenât at the
OâReilly site).
However, this query will work just fine:
site:oreilly.com inurl:"*.oreilly" -inurl:"www.oreilly"
This query says to Google, âLook on the site OâReilly.com with page URLs that contain the string `*.oreillyâ (remember the full-word wildcard? [Hack #13]) but ignore URLs with the string `www.oreillyââ (because thatâs a subdomain youâre already very familiar with).
Get Google Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.