I want to add robots.txt to my Laravel project but robots.txt packages I found are not compatible with Laravel 9+ so if you know there is any tutorial or package for latest version of Laravel, please share. Thanks.
I want to add robots.txt to my Laravel project but robots.txt packages I found are not compatible with Laravel 9+ so if you know there is any tutorial or package for latest version of Laravel, please share. Thanks.
2
Answers
To add a robots.txt file for a Laravel 9+ application, follow these steps:
Create a new file named robots.txt in the public directory of your Laravel project. You can use any text editor to create this file.
Open the
robots.txt
file and add the following lines:Use the URL in your Routes files (web.php ++) as reference. Work through each route, adding each
/names-of-different-areas-in-my-site/..
listing each route/directory you know to contain files that shouldn’t be crawled, in your robots.txt file under a Disallow: block/column/array (verbose terminology here, because each to their own and it’s anyones guess how you wanna term them)