.htaccess code to discourage search engines from indexing your website
For some reasons you might need to discourage search engines from indexing your website, most times if your website is still in development stage.
Using a robots.txt is no longer advised, according to this yoast article so using htaccess might just be what you need.
I will assume you know your way around creating a htaccess file or editing it if it already exists.
so just add these lines in your htaccess file.
<IfModule mod_headers.c> Header set X-Robots-Tag "noindex, nofollow, noarchive" <FilesMatch "\.(doc|pdf|png|jpe?g|gif)$"> Header set X-Robots-Tag "noindex, noarchive, nosnippet" </FilesMatch> </IfModule>