Robots.txt optimization is one of the smallest jobs in search, and one of the easiest to get wrong. A single misplaced line can stop Google from reaching your service pages, while a sensible file keeps crawlers focused on the pages that bring in qualified inquiries. When we run SEO for businesses in Dubai and Abu Dhabi, the robots.txt file is one of the first things we open.
This guide explains what the file actually controls, what it cannot do, and how to write and test one that supports your rankings. It sits within the wider work of technical SEO, so we keep the focus on decisions you can make and check yourself.
What robots.txt does and does not control
The robots.txt file lives at the root of your domain, for example yourdomain.com/robots.txt. Before a well-behaved crawler requests pages, it reads this file to learn which paths it may fetch. Each subdomain and protocol has its own file, so shop.yourdomain.com needs separate rules from the main site.
The file manages crawling, not indexing. This distinction matters more than anything else in this article.
- It can ask crawlers to skip folders, parameters or file types that waste crawl activity.
- It can point crawlers to your XML sitemap.
- It cannot remove a page from Google. A blocked URL can still appear in results if other pages link to it, usually without a description.
- It cannot protect private content. The file is public, and anyone can read it. Use passwords or server rules for anything confidential.
If you want a page kept out of search results, allow crawling and add a noindex meta tag or X-Robots-Tag header instead. Google stopped supporting noindex rules inside robots.txt in 2019, so those lines are simply ignored.
The directives you will actually use
Most sites need only a handful of lines. The syntax is simple, but precision matters because paths are case sensitive and rules apply to everything that starts with the path you give.
| Directive | What it does | Example |
|---|---|---|
| User-agent | Names the crawler the rules apply to | User-agent: * |
| Disallow | Asks the crawler not to fetch a path | Disallow: /cart/ |
| Allow | Opens a path inside a blocked folder | Allow: /wp-admin/admin-ajax.php |
| Sitemap | Gives the full URL of your sitemap | Sitemap: https://yourdomain.com/sitemap.xml |
Google also supports two wildcards. An asterisk matches any sequence of characters, and a dollar sign marks the end of a URL. For example, a rule that disallows paths ending in .pdf would use both. Google ignores the crawl-delay directive, although some other search engines read it.
When rules conflict, Google follows the most specific matching rule, which is the one with the longest path. If an Allow and a Disallow are equally specific, Google uses the less restrictive one, the Allow.
A step-by-step approach to robots.txt optimization
Good robots.txt optimization starts with your site, not with a template copied from another business. The right file for a five-page consultancy is very different from the right file for a store with thousands of filtered category URLs.
- Read the current file. Open yourdomain.com/robots.txt and note every rule. Many sites carry lines left behind by a previous developer or a staging setup.
- List the pages that earn business. Service pages, location pages, product and category pages, and articles that attract inquiries must all stay crawlable.
- Find crawl waste. Internal search results, cart and checkout steps, endless filter combinations and session parameters are common candidates.
- Write the smallest set of rules that blocks the waste without touching valuable pages.
- Keep resources open. Do not block CSS, JavaScript or image folders that pages need to render. Google renders pages much like a browser, and blocked files can make a page look broken to it.
- Add your sitemap line with the full absolute URL.
- Test before and after publishing, then monitor Search Console for new blocked pages.
Common patterns for WordPress and ecommerce sites
Many sites in the UAE run on WordPress, often with WooCommerce for AED payments. A sensible starting point for these sites looks like this, written out as plain lines:
- User-agent: *
- Disallow: /wp-admin/
- Allow: /wp-admin/admin-ajax.php
- Disallow: /search/
- Disallow: /cart/
- Disallow: /checkout/
- Disallow: /my-account/
- Sitemap: https://yourdomain.com/sitemap_index.xml
Adjust these to your own URL structure, and note that WordPress search results usually use an s parameter rather than a /search/ folder, so check how your theme builds them. Bilingual sites deserve extra care. If your Arabic pages sit under /ar/, make sure no rule written for an English folder accidentally matches the Arabic paths as well. Faceted navigation on stores is the other big area: blocking parameter combinations such as sort order or price filters can save crawl activity, but only block the filters you never want found. A filtered page for a popular brand or color may be worth keeping crawlable and indexable as a landing page.
When blocking is the wrong tool
Duplicate pages are often better handled with canonical tags or redirects than with robots.txt. If Google cannot crawl a duplicate URL, it cannot see the canonical tag on it either, so link signals may not consolidate the way you want.
Mistakes that quietly hurt rankings
Most robots.txt problems are not dramatic. They sit unnoticed for months while traffic slowly drops. These are the issues we see most often during audits.
| Mistake | Effect | Fix |
|---|---|---|
| Disallow: / left from staging | Whole site blocked from crawling | Remove the rule at launch and add a launch checklist step |
| Blocking CSS or JS folders | Pages render poorly for Google | Allow theme and plugin asset paths |
| Using robots.txt to hide pages | URLs still indexed without snippets | Use noindex and allow crawling |
| Rules too broad | Valuable pages blocked by prefix matching | Use precise paths and the $ end marker |
| Wrong file location or case | Crawlers cannot find the rules | Serve lowercase robots.txt at the root |
Server behavior matters too. If the file returns a server error, Google may pause crawling the site until it can read it again. If it returns a 404, Google treats the site as having no restrictions. Keep the file under 500 KiB, since Google ignores content beyond that limit.
Testing and monitoring your file
Every change should be tested. Google Search Console includes a robots.txt report that shows which version of the file Google last fetched and flags parsing problems. The URL Inspection tool tells you whether a specific page is blocked by robots.txt, which is the fastest way to check an important service page.
After a change, watch these signals over the following weeks:
- The Pages report in Search Console, especially the “Blocked by robots.txt” and “Indexed, though blocked by robots.txt” entries.
- The Crawl Stats report, to see whether crawling shifts toward the pages you care about.
- Organic landing pages in GA4, to confirm that key pages keep their traffic.
Google caches robots.txt, usually for up to a day, so changes are not picked up the moment you publish. Plan larger changes outside your busiest sales periods and keep a dated copy of each version so you can roll back quickly.
AI crawlers and your robots.txt
A newer question from clients is how to handle crawlers used by AI companies. Several of them publish their own user-agent names and state that they respect robots.txt, so you can choose to allow or block them with specific rules. Google-Extended, for example, is a separate token that controls whether content may be used for some of Google’s AI models, and it does not affect how Google Search crawls or ranks your site.
The decision is commercial. If you want your brand mentioned in AI assistants, blocking every AI crawler may reduce that visibility. If your content is your product, such as paid research, you may prefer to restrict it. Write the rule deliberately and review it as these crawlers and their policies change.
Frequently asked questions
Does every website need a robots.txt file?
No. Without a file, search engines assume they may crawl everything, which is fine for many small sites. A file becomes useful once you have areas that waste crawl activity, such as internal search, carts or filter parameters, or when you want to point crawlers to your sitemap. If you add one, keep it short and test it.
Can robots.txt improve my rankings directly?
Not directly. Robots.txt optimization helps search engines spend their crawling on the pages that matter, and it prevents accidental blocks that stop pages ranking at all. The gains come from better crawling and fewer errors, not from the file itself being a ranking signal. Content, links and page experience still drive positions.
How do I remove a page from Google if robots.txt will not do it?
Allow the page to be crawled and add a noindex meta tag or X-Robots-Tag header, then wait for Google to recrawl it. For urgent cases, the Removals tool in Search Console can hide a URL temporarily while the noindex takes effect. For private content, protect it with a password rather than relying on search rules.
Should I block my staging site with robots.txt?
A robots.txt block helps, but password protection is the safer choice for staging sites, because blocked URLs can still be indexed if they are linked from somewhere. Whichever method you use, add a launch step to remove the block on the live domain. A forgotten staging rule is one of the most common causes of sudden traffic loss.
A cleaner path for search engines
A well-written robots.txt file is short, deliberate and tested. It keeps crawlers away from low-value URLs, leaves your service and product pages open, and points directly to your sitemap. Reviewed alongside your sitemap and site structure, it supports the pages that bring in inquiries rather than working against them.
If you would like a second pair of eyes on your robots.txt file or wider crawl setup, the Bdazzil team is happy to review it with you and talk through what we find.