Domain & Hosting
Host sites on platform subdomains or connect custom domains with automatic SSL.
Overview
SiteBuilder supports two hosting modes for client sites:
| Mode | URL Example | Setup Required | Plan |
|---|---|---|---|
| Platform Subdomain | mysite.yourdomain.com |
None (automatic) | All plans (Free) |
| Custom Domain | www.clientsite.com |
DNS configuration + verification | Starter+ |
The subdomain-router.php file handles all routing. When a request comes in, it checks the hostname — if it's a subdomain of your platform domain, it serves the matching site. If it's an external domain, it looks up which site has that domain verified.
Prerequisites (One-Time Server Setup)
Before domain routing works, complete these steps on your production server:
1. Set Environment Variables
Add these to your .env file:
# Your platform's main domain (without www)
PLATFORM_DOMAIN=dedicinfotech.com
# Your server's public IP address (for A record DNS verification)
SERVER_IP=185.199.108.153
2. Run Database Migration
Import config/domain-migration.sql in phpMyAdmin (SQL tab → paste & execute). This adds:
subdomaincolumn to sites tabledomain_verified,domain_verified_atcolumnsssl_status,ssl_issued_at,ssl_expires_atcolumnsdomain_verificationstable (verification log)platform_settingstable
The migration uses IF NOT EXISTS and INSERT IGNORE patterns — running it again won't break anything.
3. Set Up Wildcard DNS
At your domain registrar, add a wildcard A record:
| Type | Name | Points To | TTL |
|---|---|---|---|
| A | * | Your server IP | 14400 |
This routes all subdomains (e.g. anything.yourdomain.com) to your server.
4. Enable the Router in .htaccess
Uncomment the subdomain router block (see section below).
Subdomain Hosting (Automatic)
Once prerequisites are done, every site is automatically available at:
https://{site-slug}.yourdomain.com
How the routing works:
- Wildcard DNS (
*.yourdomain.com) routes all subdomains to your server - Apache hits
.htaccess→ matches the subdomain pattern → routes tosubdomain-router.php - Router extracts the subdomain from the HTTP hostname
- Looks up the site by slug in the
sitestable - Serves static files from
/sites/{slug}/directory
Once wildcard DNS + .htaccess are configured, every new site you create is instantly live on its subdomain. The subdomain matches the site slug.
Reserved subdomains (these always serve the main platform):
www,admin,api,mail,ftp,cpanel,webmail,ns1,ns2
.htaccess Configuration
In your root .htaccess, find and uncomment this block for production:
# ── Subdomain / custom-domain router ─────────────────────────────
# Subdomain routing: slug.yourdomain.com → subdomain-router.php
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^localhost [NC]
RewriteCond %{HTTP_HOST} !^127\.0\.0\.1 [NC]
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+\.[^.]+$ [NC]
RewriteRule ^ subdomain-router.php [L]
# Custom domain catch-all (domains NOT matching platform domain):
RewriteCond %{HTTP_HOST} !yourdomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^localhost [NC]
RewriteRule ^ subdomain-router.php [L]
Replace yourdomain\.com with your actual platform domain (dots escaped with backslash). For example: dedicinfotech\.com
Also update RewriteBase for production:
# For domain root (Hostinger):
RewriteBase /
# For subdirectory (e.g. public_html/sitebuilder/):
RewriteBase /sitebuilder/
Wildcard DNS Setup (Hostinger)
Step-by-step for Hostinger (similar process for other registrars):
- Login to hPanel → Domains → select your domain
- Go to DNS / Nameservers → DNS Records
- Click Add Record and fill in:
Type Name (Host) Points To (Value) TTL A *Your server IP address 14400 - Click Save
- Wait 15 minutes to 48 hours for DNS propagation
- Test: visit
test123.yourdomain.com— should hit your server (may show "Site Not Found" which is correct)
Wildcard subdomains may require Business plan or higher on Hostinger shared hosting. Check hPanel → Hosting → Subdomains to confirm wildcard support. If not available, consider upgrading or using a VPS.
For VPS (DigitalOcean, AWS, etc.)
Add a wildcard Apache virtual host:
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias *.yourdomain.com
DocumentRoot /var/www/sitebuilder
<Directory /var/www/sitebuilder>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then restart Apache:
sudo systemctl restart apache2
Custom Domain Setup (Per Site)
Users can connect their own domain (e.g. www.clientsite.com) to any site. Here's the full flow:
Step 1: Add Domain in Site Settings
- Go to Admin → Sites
- Click the site's Settings icon
- Enter the custom domain in the Domain field (e.g.
www.clientsite.com) - Save
Step 2: Configure DNS at Client's Registrar
The client needs to add one of these DNS records at their domain registrar:
| Type | Name / Host | Value / Points To | When to Use |
|---|---|---|---|
| CNAME | www |
yourdomain.com (your platform domain) |
Recommended — works with most registrars |
| A | @ (root) |
Your server IP address | Use if registrar doesn't support CNAME on root domain |
Step 3: Verify DNS
- Wait for DNS propagation (15 min – 48 hours)
- Go to Admin → Sites → Manage Domains for the site
- Click "Verify DNS Now"
- The system checks both CNAME and A records automatically
- Once verified, the site is live on the custom domain
The verification is handled by api/verify-domain.php which uses dig (with fallback to PHP's dns_get_record) to check DNS records. It verifies CNAME pointing to your platform domain, or A record pointing to your SERVER_IP.
Step 4: Install SSL for Custom Domain
Custom domains need their own SSL certificate (not covered by your wildcard cert):
- Hostinger: hPanel → SSL → Install for the custom domain (free Let's Encrypt)
- VPS:
sudo certbot --apache -d clientdomain.com -d www.clientdomain.com
SSL / HTTPS
| Hosting Mode | SSL Method | Notes |
|---|---|---|
| Platform subdomains | Wildcard SSL certificate (*.yourdomain.com) |
On Hostinger: enable in hPanel → SSL. Covers all subdomains automatically. |
| Custom domains (Hostinger) | Per-domain SSL via hPanel | hPanel → SSL → select the custom domain → Install (free Let's Encrypt) |
| Custom domains (VPS) | Let's Encrypt via Certbot | sudo certbot --apache -d domain.com -d www.domain.com |
The .htaccess includes an HTTPS redirect rule (enabled by default for non-localhost):
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^localhost [NC]
RewriteCond %{HTTP_HOST} !^127\.0\.0\.1 [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Troubleshooting
| Issue | Solution |
|---|---|
| Subdomain shows "Site Not Found" | Check the site slug matches, and /sites/{slug}/index.html exists. Regenerate the site if needed. |
| Subdomain shows platform homepage instead of site | The subdomain router block in .htaccess is still commented out. Uncomment it. |
| Custom domain says "DNS not verified" | DNS may not have propagated yet (can take up to 48h). Verify with: dig yourdomain.com A or dig www.yourdomain.com CNAME |
| Verification says "A record points to X but expected Y" | Ensure SERVER_IP in .env matches your actual server's public IP address. |
| SSL not working on custom domain | Custom domains need their own SSL certificate — install separately via hPanel or Certbot. |
| Wildcard subdomains not working on Hostinger | Shared hosting may not support wildcard subdomains. Upgrade to Business plan or use a VPS. |
| "SERVER_IP is not set" error in verification | Add SERVER_IP=your.ip.here to .env. Find your IP with curl ifconfig.me on the server. |
| Custom domain shows wrong site | Check that only one site has that domain set. Look in DB: SELECT * FROM sites WHERE domain LIKE '%clientdomain%' |
Files Reference
All files involved in the domain/hosting system:
| File | Purpose |
|---|---|
.env | PLATFORM_DOMAIN and SERVER_IP configuration |
.htaccess | Subdomain/custom domain rewrite rules (uncomment for production) |
subdomain-router.php | Main router — resolves hostname to site, serves static files |
config/domain-migration.sql | Database migration — adds subdomain/domain columns (run once) |
admin/domains.php | Domain management UI per site (DNS instructions, verify button) |
api/verify-domain.php | DNS verification API — checks CNAME and A records |
- ✅
PLATFORM_DOMAINset in.env - ✅
SERVER_IPset in.env - ✅
config/domain-migration.sqlimported - ✅ Wildcard DNS record (
*→ server IP) added at registrar - ✅ Subdomain router block uncommented in
.htaccess - ✅
RewriteBase /set (for domain root deployment) - ✅ Wildcard SSL certificate installed (for subdomains)
- ✅ Test: visit
slug.yourdomain.com— site loads