This document provides a detailed explanation of how we manage hosting multiple sites on our server. We will be hosting sites for our clients as well as for our own use. The following steps outline the process of mapping domain names to site configurations and setting up site-specific routes.
p> **Overview of the Process:** 1. **Retrieve Domain Name:** Extract the domain name from the request and store it in the session as `HostName`. The domain name is typically in the format `http://shanta.local:3000/`. 2. **Set Site Name:** Use the `HostName` to determine the `SiteName`. 3. **Domain-Site Mapping:** The mapping between `HostName` and `SiteName` is stored in the `sitedomain` table. The `DomainName` field stores the domain, and the `SiteName` field stores the corresponding site ID. 4. **Site Details Retrieval:** Use the `site_id` from the `sitedomain` table to fetch site setup details from the `sites` table. This includes parameters such as the site controller, CSS view name, site display name, email address, etc. 5. **Site Controller Setup:** The site controller is responsible for setting site-specific routes.
**Detailed Explanation:** The following sections explain the code used to implement the above steps, highlighting the purpose of each part and suggesting improvements.
In the `auto` subroutine of the `Root` controller, the following operations are performed to set up the site-specific configurations.