I have an angular app served through nginx. For googlebot I want to serve a different static html file so that it can index properly, is the following nginx config correct? (I don't want to complicate the setup using phantomjs, I want to explore other options like sitemap.xml only if nginx can't do this job)

location / {
    if ($http_user_agent ~ Googlebot) {
        rewrite ^/(.*)$ /forgooglebot.html break;
    root /usr/share/nginx/app;
    try_files $uri $uri/ /index.html;
  • 2
    Did you...try it? – Nathan C Oct 15 '13 at 14:20
  • Set your browser's user agent to Googlebot and see if it's working. – ceejayoz Oct 15 '13 at 14:30
  • It works indeed. thanks. verified using "curl -A Googlebot" command – Krishna Srinivas Oct 15 '13 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.