diff --git a/nginx.conf.sample b/nginx.conf.sample
index 01b163498156956cb37f9ea99a5f5f9c9817981c..0d7568caeb529d91aafcee340a721c5bc3d42a6d 100644
--- a/nginx.conf.sample
+++ b/nginx.conf.sample
@@ -33,7 +33,7 @@ location /setup {
         include        fastcgi_params;
     }
 
-    location ~ /setup/(?!pub/). {
+    location ~ ^/setup/(?!pub/). {
         deny all;
     }
 }
@@ -41,7 +41,7 @@ location /setup {
 location /update {
     root $MAGE_ROOT;
 
-    location ~ /update/index.php {
+    location ~ ^/update/index.php {
         fastcgi_pass   fastcgi_backend;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
@@ -49,7 +49,7 @@ location /update {
     }
 
     # deny everything but index.php
-    location ~ /update/(?!pub/). {
+    location ~ ^/update/(?!pub/). {
         deny all;
     }
 }