1

To perform domain verification for google, I must serve a file at the root of my domain. The filename is typically googleXXXXXXXXXXXXX.html (those Xs are a hex substring).

So I copied it to my site's root (/var/www/html/), and edited nginx's config like this:

location ~* /google.+\.html$ {
  alias /var/www/html/$1;
}    

Though I get a 404. I didn't hardcode the filename, but it fails even if I do.


Please note I know of this widely-used trick:

location = /googleXXXXX.html {
  rewrite ^/(.*) $1;
  return 200 "google-site-verification: $uri";
}

But I don't want to do that because it's not future proof - I want to serve the file as is.

lonix
  • 1,119

1 Answers1

0

Unsure why alias didn't work, but this works for me:

location ~* /google.+\.html$ {
  try_files $uri =404;
}
lonix
  • 1,119