How to exclude urls from robots.txt file?

by jaycee_rowe , in category: SEO , 8 months ago

How to exclude urls from robots.txt file?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by cameron_walter , 8 months ago

@jaycee_rowe 

To exclude URLs from being crawled by web robots or spiders in the robots.txt file, you can use the "Disallow" directive. Here's how you can exclude specific URLs:

  1. Open your robots.txt file in a text editor or create a new file if you don't have one already.
  2. Use the "Disallow" directive followed by the URL path you want to exclude. For example, if you want to exclude a page called "examplepage.html" in the root directory, the entry would be: Disallow: /examplepage.html Note: The path is case-sensitive.
  3. If you want to exclude an entire directory, include a trailing slash at the end of the path. For example, to exclude the directory "exampledir", the entry would be: Disallow: /exampledir/
  4. Save the robots.txt file and upload it to the root directory of your website.
  5. Repeat steps 2-4 for each URL or directory you want to exclude.


Remember, not all web crawlers strictly adhere to the robots.txt file instructions. While most popular search engines respect it, other bots may ignore the directives.