How to allow crawlers access to index.php only, using robots.txt?

Member

by jamison , in category: SEO , 4 months ago

How to allow crawlers access to index.php only, using robots.txt?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by zion , 4 months ago

@jamison 

To allow crawlers access to only the index.php file using the robots.txt file, you can add the following lines:

1
2
3
User-agent: *
Disallow: /    # disallow all URLs by default
Allow: /index.php    # allow access to the index.php file


Explanation:

  • The User-agent: * line applies the rules to all web crawlers.
  • The Disallow: / line tells crawlers not to access any page on the website.
  • The Allow: /index.php line specifically allows access to the index.php file.


Make sure to place this robots.txt file in the root directory of your website. However, keep in mind that the Allow directive is not supported by all search engine bots, so some crawlers may still attempt to access other files even if you have specified only the index.php file to be allowed.