أهم النقاط
- robots.txt tells crawlers which paths they may fetch.
- Disallowing a page doesn't remove it from search — use noindex for that.
- A single wrong line can hide your whole site from search engines.
A sensible default
User-agent: *
Disallow:
Sitemap: https://example.com/sitemap.xml
An empty Disallow: allows everything. The Sitemap line helps crawlers find your pages.
WordPress example
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://example.com/wp-sitemap.xml
Rules to remember
- Paths are case-sensitive and match by prefix:
Disallow: /privatealso blocks/private-offers. *matches any characters and$anchors the end:Disallow: /*.pdf$.- Don’t block CSS, JavaScript or images — search engines need them to render pages.
Disallow: /blocks the whole site. Staging sites use it; production sites almost never should.
Create and test
- Generate a file with the robots.txt generator or write it by hand.
- Upload it to your site’s document root (
public_html). - Check it with the robots.txt checker and in Search Console’s robots.txt report.
الأسئلة الشائعة
Where does robots.txt go?
At the root of the host: https://example.com/robots.txt. Each subdomain needs its own.
Can robots.txt keep private files secret?
No. It's public and only advisory. Protect private files with passwords or by not putting them on the public web server.