Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

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

TypeGood ForProsCons
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

  1. Build your site folder (index.html, /css, /img, /js).
  2. Choose a host (static host, shared host, etc.).
  3. Upload your files (GUI uploader, FTP/SFTP, or Git).
  4. Connect your custom domain with DNS (A/CNAME records).
  5. 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).

RecordPurposeExample
ADomain → IPv4 addressexample.com → 93.184.216.34
AAAADomain → IPv6 addressexample.com → 2606:2800:...
CNAMEAlias → Canonical namewww → example.com
MXEmail routingexample.com → mail.provider.com
TXTVerification, 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).

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.