skip to Main Content

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


  1. 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:

    User-agent: *
    Disallow: /admin
    
    Login or Signup to reply.
  2. 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)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search