I'm looking for an URL that goes directly to the first Google hit from a certain domain as in "I'm Feeling Lucky" but limited to a certain domain.

I'm using this formula, but it typically doesn't work.


Edit: It seems to work a lot of the time actually. However, there are quite a few cases in which it will not work.

5 Answers 5


Use links like https://www.google.com/search?btnI=1&q=%s site:developer.mozilla.org

btnI=1 makes the difference from a normal request.


I solved this by switching to an equivalent service by another search engine.

While the formula given in the question often works, Google will sometimes chicken out and go to a regular search results page rather than going directly to the top hit.

DuckDuckGo never chickens out. It always goes to the top hit.

Therefore I am using DuckDuckGo for this particular service from now on.

Here is the formula for DuckDuckGo:


For example:


This is where I learned it, by the way.

  • This doesn't work as a link from an external site.
    – Semra
    Apr 5, 2023 at 12:44

In my experience, using an ordinary "btnI=1&q=" Google URL worked fine in the past. But for a few years I've been experiencing unreliable "lucky" redirects, as noticed by the poster of this question. After some troubleshooting I discovered that one can fix this with a "Referer: http://www.google.com/" header:

w3m -header "Referer: http://www.google.com/" "http://www.google.com/search?ie=ISO-8859-1&hl=en&source=hp&q=happy+nation+lyrics&btnI=I%27m+Feeling+Lucky&gbv=1"

For me, removing the header parameter in the above command causes the redirect not to work. Redirect also breaks if you remove the "www." in the "http://" URL.

I figured this out by comparing the URLs and headers in the HTTP requests generated by manually clicking on the "Lucky" button vs loading the URL directly. https://serverfault.com/questions/504431/human-readable-format-for-http-headers-with-tcpdump (Unfortunately this snooping method only works with HTTP, not HTTPS)

  • As of October 2019, "Google lucky" URLs sometimes produce a special redirect page, for me at least, that needs extra parsing to get the URL of the top result. I just wrote a script which does this, but it is not very elegant. Dec 10, 2019 at 4:16

Use this one (Twitter as example, you change this to your search words)


To stop the redirect notice use this small extension.


Try this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.