{"id":687,"date":"2016-11-07T00:00:00","date_gmt":"2016-11-07T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/websitehow-to-block-search-engines-using-robotstxt\/"},"modified":"2026-03-09T19:20:12","modified_gmt":"2026-03-09T19:20:12","slug":"how-to-block-search-engines-using-robotstxt","status":"publish","type":"post","link":"\/ng\/tutorials\/how-to-block-search-engines-using-robotstxt","title":{"rendered":"Robots.TXT disallow: how does it block search engines"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Are you looking for a way to control how search engine bots crawl your site? Or do you want to make some parts of your website private? You can do it by modifying the <strong>robots.txt<\/strong> file with the<strong> disallow<\/strong> command.<\/p><p>In this article, you will learn what<strong> robots.txt<\/strong> can do for your site. We&rsquo;ll also show you how to use it in order to block search engine crawlers.<\/p><figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Build-WordPress-Website-in-9%20Steps.pdf\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png\/public\" alt=\"\" class=\"wp-image-69276\" style=\"width:840px;height:auto\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-robots-txt\">What Is Robots.txt<\/h2><p><strong>Robots.txt <\/strong>is a plain text file used to communicate with web crawlers. The file is located in the root&nbsp;directory of a site.<\/p><p>It works by telling the search bots which parts of the site should and shouldn&rsquo;t be scanned. It&rsquo;s up to <strong>robots.txt <\/strong>whether the bots are allowed or disallowed to crawl a website.<\/p><p>In other words, you can configure the file to <a href=\"\/ng\/tutorials\/prevent-search-engines-from-indexing-wordpress\" target=\"_blank\" rel=\"noreferrer noopener\">prevent search engines from scanning and indexing pages<\/a> or files on your site.<\/p><h2 class=\"wp-block-heading\" id=\"h-why-should-i-block-a-search-engine\">Why Should I Block a Search Engine<\/h2><p>If you want to block crawlers from accessing your entire website, or if you have sensitive information on pages that you want to make private. Unfortunately, search engine bots can&rsquo;t automatically distinguish between public and private content. In this case, restricting access is necessary.<\/p><p>You can also restrict bots from crawling your entire site. Especially if your website is in maintenance mode or staging.<\/p><p>Another use of<strong> robots.txt<\/strong> is to prevent <a href=\"https:\/\/moz.com\/learn\/seo\/duplicate-content\" target=\"_blank\" rel=\"noreferrer noopener\">duplicate content<\/a> issues that occur when the same posts or pages appear on different URLs. Duplicates can negatively impact <a href=\"\/ng\/tutorials\/what-is-seo\/\" target=\"_blank\" rel=\"noreferrer noopener\">search engine optimization (SEO)<\/a>.<\/p><p>The solution is simple &ndash; identify duplicate content, and disallow bots from crawling it.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-use-robots-txt-to-disallow-search-engines\">How to Use Robots.txt to Disallow Search Engines<\/h2><p>If you want to check your site&rsquo;s <strong>robots.txt <\/strong>file, you can view it by adding <strong>robots.txt<\/strong> after your site&rsquo;s URL, for example, <strong>www.myname.com\/robots.txt<\/strong>. You can edit it through your web hosting control panel&rsquo;s file manager, or an <a href=\"\/ng\/tutorials\/ftp\/filezilla-ftp-configuration\" target=\"_blank\" rel=\"noreferrer noopener\">FTP client<\/a>.<\/p><p>Let&rsquo;s configure the <strong>robots.txt<\/strong> file via Hostinger&rsquo;s <strong>hPanel&rsquo;s<\/strong> file manager. First, you have to enter the <strong>File Manager<\/strong> in the<strong> Files<\/strong> section of the panel. Then, open the file from the<strong> public_html<\/strong> directory.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-robots.txt_.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"194\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-robots.txt_.png\/public\" alt=\"The public_html directory with the \" class=\"wp-image-80668\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-robots.txt_.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-robots.txt_.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-robots.txt_.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-files-filemanager-public_html-robots.txt_.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>If the file isn&rsquo;t there, you can create it manually. Just click the <strong>New File<\/strong> button at the top right corner of the file manager, name it <strong>robots.txt<\/strong> and place it in <strong>public_html<\/strong>.<\/p><p>Now you can start adding commands to the file. The two main ones you should know are:<\/p><ol class=\"wp-block-list\">\n<li><strong>User-agent<\/strong> &ndash; refers to the type of bot that will be restricted, such as <a href=\"https:\/\/developers.google.com\/search\/docs\/crawling-indexing\/googlebot\" target=\"_blank\" rel=\"noreferrer noopener\">Googlebot<\/a> or <a href=\"https:\/\/www.bing.com\/webmasters\/help\/which-crawlers-does-bing-use-8c184ec0\" target=\"_blank\" rel=\"noreferrer noopener\">Bingbot<\/a>.<\/li>\n\n\n\n<li><strong>Disallow <\/strong>&ndash; is where you want to restrict the bots.<\/li>\n<\/ol><p>Let&rsquo;s look at an example. If you want to prevent Google&rsquo;s bot from crawling on a specific folder of your site, you can put this command in the file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">User-agent: Googlebot&nbsp;\nDisallow: \/example-subfolder\/<\/pre><p>You can also block the  search bots from crawling on a specific web page. If you want to block Bingbot from a page, then you can set the command like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">User-agent: Bingbot\n\nDisallow: \/example-subfolder\/blocked-page.html<\/pre><p>Now, what if you want the<strong> robots.txt<\/strong> file to disallow all search engine bots? You can do it by putting an<strong> asterisk (*)<\/strong> next to <strong>User-agent<\/strong>. And if you want to prevent them from accessing the entire site, just put a <strong>slash (\/)<\/strong> next to <strong>Disallow<\/strong>. Here&rsquo;s how it looks:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">User-agent: *\n\nDisallow: \/<\/pre><p>You can set up different configurations for different search engines by adding multiple commands to the file. Also, keep in mind that the changes take effect after you save the <strong>robots.txt<\/strong> file.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Now you&rsquo;ve learned how to modify the <strong>robots.txt<\/strong> file. This lets you manage search engine bot access to your website. Now you can rest easy knowing that only what you want to be found on search engine result pages will show up there.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Learn More About Website Optimization<\/h4>\n                    <p><a href=\"\/ng\/tutorials\/website-optimization\">What Is Website Optimization<\/a><br>\n<a href=\"\/ng\/tutorials\/what-is-a-sitemap\">What Is a Sitemap<\/a><br>\n<a href=\"\/ng\/tutorials\/submit-website-to-search-engines\">How to Submit Your Website to Search Engines<\/a><br>\n<a href=\"\/ng\/tutorials\/website-localization\">Website Localization Complete Guide<\/a><\/p>\n                <\/div>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you looking for a way to control how search engine bots crawl your site? Or do you want to make some parts of your website private? You can do it by modifying the robots.txt file with the disallow command. In this article, you will learn what robots.txt can do for your site. We&rsquo;ll also [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/how-to-block-search-engines-using-robotstxt\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Block Search Engines Using robots.txt disallow Rule","rank_math_description":"You can disallow all search engine bots to crawl on your site using the robots.txt file. In this article, you will learn exactly how to do it!","rank_math_focus_keyword":"robots txt disallow all","footnotes":""},"categories":[22619],"tags":[],"class_list":["post-687","post","type-post","status-publish","format-standard","hentry","category-seo"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-criar-robots-txt-bloquear-mecanismos-busca","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-bloquear-los-motores-de-busqueda-utilizando-robotstxt","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-bloquear-los-motores-de-busqueda-utilizando-robotstxt","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-bloquear-los-motores-de-busqueda-utilizando-robotstxt","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-bloquear-los-motores-de-busqueda-utilizando-robotstxt","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-criar-robots-txt-bloquear-mecanismos-busca","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-block-search-engines-using-robotstxt","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=687"}],"version-history":[{"count":21,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/687\/revisions"}],"predecessor-version":[{"id":145425,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/687\/revisions\/145425"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}