Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module dynamically serves a different robots.txt file based on the website's environment. It ensures search engines only index your production site by serving a custom file for production and a disallow-all file for development and staging environments.

Robots Rerouter dynamically serves robots.txt based on environment. Prevents search engine indexing of non-production sites with minimal config.

Features

Robots Rerouter serves a different robots.txt response depending on the current domain.

βœ… Serves a custom robots.txt for production
🚫 Serves a disallow-all fallback for non-production environments (QA, Stage, Dev)
πŸ” Prevents accidental indexing of staging/test sites by search engines
πŸ›  Admin config form allows you to:
- Define the production hostname (e.g. www.example.com)
- Specify file paths for both production and fallback robots.txt

🧩 Smart behavior:
- Automatically creates the folders and files under public:// if they don’t exist
- Ensures secure, sandboxed file handling even on hosted environments like Acquia

Use Cases:
- You're managing multiple environments and want only the live site indexed
- You've seen Google index staging/dev accidentally before and need a safety net
- You're using CI/CD or Composer-based deployments and want to avoid .htaccess hacks

Post-Installation

After enabling the module:

1. Visit:
/admin/config/search/robots-rerouter

2. Configure:
- Production Hostname (e.g., www.example.com)
- Production File Path: e.g., robots/good_robots.txt
- Fallback File Path: e.g., robots/nocrawl_robots.txt

3. On save:
- Any missing folders or files will be automatically created in public://

Then when a user visits /robots.txt:
- If the domain matches your production hostname, it serves the production file
- Else, it serves the disallow-all fallback file

Additional Requirements

- No contributed modules are required.
- Files are created automatically under public://, but you may optionally upload your own content (especially the production robots.txt).
- Example fallback content:
User-agent: *
Disallow: /

Activity

Total releases
2
First release
Aug 2025
Latest release
11 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
1.0.0 Stable Aug 7, 2025
1.0.x-dev Dev Aug 7, 2025