How to Block OpenAI's ChatGPT AI Bots from Crawling Your Website Content and Using It

Updated by shortbuzz

OpenAI logo chatgpt

For the purpose of learning, ChatGPT has access to website content. You can prevent your content from being used as AI training data in below given method.

You can use a number of techniques to block access if you don't want openAI's chatgpt bot to access the information on your website.

Block chatgpt to crawl your website content using "robots.txt" file

By using a file called "robots.txt," you can restrict access to your website's content in one standard way. This file contains instructions on which pages or folders on your website should not be scanned or indexed by search engines and other bots. To prevent access from some bots, you can add certain user agents, such as "ChatGPT" or "OpenAI".

You can create a robots.txt file by following these steps:

User-agent: ChatGPT
Disallow: /

User-agent: OpenAI
Disallow: /
  1. Create a file called "robots.txt" in plain text.
  2. Add above given code to the file
  3. After saving the file as "robots.txt", upload it to your website's root directory for example

These lines will tell ChatGPT and OpenAI not to visit any of your website's pages.  However, it is important to note that these rules are optional, and not all bots will follow them.

Using a ".htaccess" to block OpenAI chatgpt access to your website content

You can prevent ChatGPT from accessing your website by placing the following code in the ".htaccess" file on your web server:

# Block ChatGPT and OpenAI
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ChatGPT [OR]
RewriteCond %{HTTP_USER_AGENT} OpenAI
RewriteRule .* - [F]

This code uses Apache's mod rewrite module to check the HTTP_USER_AGENT header of incoming requests and rejects any requests from ChatGPT or OpenAI with a 403 Forbidden message.

To implement this code, follow the below steps:

  1. Create or edit the.htaccess file in your website's root directory (Your .htaccess file is always hidden; to view it, go to Settings in the top right corner of the Cpanel and select "Show Hidden Files (dotfiles)." and save, now you will see .htaccess file on your file list).
  2. In the .htaccess file, copy and paste the above code and save it.

Using Nginx to block OpenAI chatgpt access to your website content

The following code can be added to your Nginx server configuration file to prevent ChatGPT bots from reading your website's content:

# Block ChatGPT and OpenAI
if ($http_user_agent ~* (ChatGPT|OpenAI)) {
    return 403;

This code checks the HTTP_USER_AGENT header of incoming requests using Nginx's "if" directive and returns a 403 Forbidden error for any requests coming from ChatGPT or OpenAI.

To implement this method, follow these steps:

  1. With a text editor, open the Nginx server configuration file. Depending on your Nginx configuration, the file can be found at either /etc/nginx/nginx.conf or /etc/nginx/sites-available/default.
  2. For your website, find the server block
  3. Save the file after adding the above code to the server block and restart the Nginx server.

Keep in mind that depending on your server and hosting environment, the exact syntax of the Nginx configuration file may vary. Please get in touch with us if you need assistance modifying the configuration file.


You can use a variety of methods to ban ChatGPT and stop it from consuming the content on your website. Creating a "robots.txt" file with instructions telling search engines and bots not to crawl or index particular pages or directories on your website is a basic approach. To prevent access by specific bots, add user agents like "ChatGPT" or "OpenAI" to the "robots.txt" file.

You can also prevent access to ChatGPT and other bots by using the .htaccess file on your web server. You can include code that looks at the HTTP_USER_AGENT header of incoming requests and sends a 403 Forbidden error to any that come from ChatGPT or OpenAI.

The HTTP_USER_AGENT header of incoming requests can be checked if you're using Nginx, and you can add code to your server configuration file that returns a 403 Forbidden error for any requests coming from ChatGPT or OpenAI.

The "robots.txt" file, the .htaccess file, or the Nginx configuration file can all be modified, but if you're unclear how, ask for our help.

More articles from shortbuzz

ecommece template tailwindcss text and businessman

Get Free TailwindCSS eCommerce Template: Build Online Store

TailwindCSS eCommerce template free: Take advantage of our template & boost your online store's sales with a visually stunning and user-friendly website design continue reading

Google sign-in button and Google logo

How to migrate from Google Sign-In API to Identity Services

Use Google Identity Services API to improve the user experience & security of your website. Replace old Google Sign-In API with new method: Full migration guide continue reading

flower with cards

TailwindCSS: Show More/Less Truncate Text using JS & Reactjs

Use TailwindCSS, JavaScript or ReactJS to create a read more & show less function with a smooth transition using tailwind multi-line-clamp truncation continue reading

Convert Number to Words

Convert Number to Words using Javascript, Jquery, ReactJS

Code and output for Convert number to words using JQuery, ReactJS, JavaScript, and TypeScript. Example: convert 1 to one continue reading

cloud server with laptop

Best web hosting service provider in Saudi Arabia (KSA)

Find the best web hosting service providers for your company in Saudi Arabia. Our detailed list includes the most cost-effective, reliable, and fast options. continue reading

Web hosting server and cloud hosting server

What is Web Hosting and Types: A Complete Beginners Guide

For creation of websites requires web hosting. Learn about many types and their advantages and disadvantages to select the best option for your website. continue reading

Using tailwind css align item in the centre of the screen text and tailwind logo

Tailwind CSS center div vertically and horizontally

Using tailwindCSS, place the div in the middle of the screen, both vertically and horizontally, using flexbox or grid system with simple explanation. continue reading

Xampp error windows

How to fix Error: MySQL shutdown unexpectedly in XAMPP

The cause of "Error: MySQL Shutdown Unexpectedly" in XAMPP, shutting down MySQL without running XAMPP as an administrator frequently leads to corruption. continue reading

Bootstrap icon and Tailwind css icon and grid layout design

How to make Tailwind CSS grid system like Bootstrap grids

Tailwind offers grid-template-column utility for creating basic grids, as well as the grid-cols-{size} & col-span-{size} utilities to create bootstrap-like grid continue reading

Python logo with folder icon and python code on computer screen in the background

Python Check If File Exists - Python Check If Directory Exists?

path.exists(path) method in python is used to check if a given file or directory exists or not; if it exists, it returns true or else return False continue reading