Brtest Tutorial
Web Hosting
Web hosting is a service that stores your website�s files on an online server so people can visit your site on the Internet. To put a site online you typically need a domain name, a host, and a way to deploy your files.
🌍 Domain vs Hosting vs DNS
- Domain: The human-friendly address (example.com).
- Hosting: The server where your files live.
- DNS: The �address book� that points your domain to your host�s IP.
Tip: You can buy a domain from a registrar and host your site somewhere else. You just connect them with DNS records.
🧩 Common Hosting Types
| Type | Good For | Pros | Cons |
|---|---|---|---|
| Static Hosting | HTML/CSS/JS sites | Fast, simple, cheap/free | No server-side code |
| Shared Hosting | Small sites/blogs | Low cost, easy panels | Performance varies |
| VPS | Growing apps | More control & power | Needs setup/maintenance |
| Dedicated | High traffic, special needs | Maximum control | Expensive, managed by you |
| Cloud | Scalable apps/APIs | Scales on demand | Complex pricing/ops |
🔐 SSL/TLS (HTTPS)
HTTPS encrypts traffic between the browser and your site. Most hosts support free certificates (e.g., Let�s Encrypt). Enable it in your control panel or via your web server.
Apache (.htaccess) � Redirect HTTP → HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
📦 How to Publish a Static Site
- Build your site folder (index.html, /css, /img, /js).
- Choose a host (static host, shared host, etc.).
- Upload your files (GUI uploader, FTP/SFTP, or Git).
- Connect your custom domain with DNS (A/CNAME records).
- Enable HTTPS (SSL/TLS).
FTP Upload (basic)
Host: ftp.yourhost.com
User: yourname
Protocol: FTP or SFTP
Remote folder: public_html or www
Upload: index.html, /css, /img, /js
Git Deploy (concept)
git init
git add .
git commit -m "Initial site"
git remote add origin <host-repo-url>
git push -u origin main
🧭 DNS Essentials
Update your domain�s DNS so it points to your host. Changes can take up to 24�48 hours (usually faster).
| Record | Purpose | Example |
|---|---|---|
| A | Domain → IPv4 address | example.com → 93.184.216.34 |
| AAAA | Domain → IPv6 address | example.com → 2606:2800:... |
| CNAME | Alias → Canonical name | www → example.com |
| MX | Email routing | example.com → mail.provider.com |
| TXT | Verification, SPF, etc. | v=spf1 include:mail.example ~all |
Tip: Use www as a CNAME to the root or point both root and www to your host. Add a redirect so there�s only one canonical URL.
📁 Directory Structure
Most shared hosts serve files from a folder like public_html or www. Your homepage should be index.html.
Typical Static Site
/public_html
index.html
/css/style.css
/js/app.js
/img/logo.png
⚙️ Server-Side (Dynamic Sites)
If your site needs a backend (databases, logins, APIs), choose hosting that supports server-side tech (e.g., Node.js, PHP, Python) and a database (MySQL, PostgreSQL). You�ll deploy app code and configure environment variables.
Environment Variables (Concept)
DATABASE_URL=mysql://user:pass@host:3306/dbname
JWT_SECRET=your-secret
NODE_ENV=production
🧰 Control Panels & Tools
- cPanel / Plesk: File manager, FTP accounts, databases, SSL, emails.
- Logs & Monitoring: Check errors, bandwidth, and uptime.
- Backups: Schedule automatic backups (daily/weekly).
- CDN: Speed up global delivery and cache static assets.
✅ Hosting Checklist
- Custom domain connected (A/CNAME)
- HTTPS enabled (redirect HTTP → HTTPS)
- Backups configured
- Uptime monitoring enabled
- Compression & caching on (static assets)
- 404 and 301 redirects configured
Basic Redirects
# Redirect old page to new page
Redirect 301 /old.html /new.html
# Force one canonical host (www → root)
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
🚀 Quick �Go Live� Paths
- Static Site: Use a static host with drag-and-drop or Git.
- WordPress: Use shared/managed WP hosting; one-click install.
- Full-stack App: Use VPS or cloud; deploy via CI/CD.
Next step: Continue to �WD Web Hosting: Deploy a Site� for a step-by-step guide (static + dynamic).