🔐 Instructions for How to Redirect HTTP to HTTPS
If your website is still accessible via HTTP, it’s time to upgrade! Redirecting all HTTP traffic to HTTPS ensures better security, trust, and SEO performance. In this blog, we’ll guide you through simple methods to force all HTTP requests to redirect to HTTPS—step-by-step.
🌐 What Is HTTPS and Why Redirect?
HTTPS (HyperText Transfer Protocol Secure) encrypts data between a browser and your server, keeping sensitive information like passwords and credit card details safe. Google also prefers HTTPS websites, giving them higher search rankings.
Benefits of HTTPS:
- 🔒 Enhanced Security
- 🔍 Better SEO
- ✅ Improved Trust & Credibility
- ⚠️ Required for Payment Gateways
🛠️ Methods to Redirect HTTP to HTTPS
1. 🔁 Using .htaccess
(for Apache Servers)
If you’re using an Apache web server, you can edit the .htaccess
file located in your site’s root directory:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
✅ This rule checks if HTTPS is off and redirects to the same URL with HTTPS enabled.
2. ⚙️ Nginx Configuration
For Nginx servers, open your config file (e.g., /etc/nginx/sites-available/yourdomain.conf
) and add the following:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
return 301 https://$host$request_uri;
}
📝 Save and restart Nginx:
sudo systemctl restart nginx
3. 🌍 cPanel Redirect (No Coding)
If your hosting provider uses cPanel, follow these steps:
- Log in to cPanel.
- Go to Domains > Redirects.
- Set Type to “Permanent (301)”.
- Choose the domain to redirect.
- In “Redirects to,” enter your HTTPS URL.
- Click Add.
📌 Great for beginners with shared hosting!
4. 🔐 Force HTTPS with Cloudflare
Using Cloudflare? It’s even easier:
- Log in to Cloudflare.
- Select your domain.
- Go to SSL/TLS > Edge Certificates.
- Toggle Always Use HTTPS to “On.”
⚡ Traffic is now auto-redirected to HTTPS without server changes.
🚨 Don’t Forget These After Redirecting:
- ✅ Ensure your SSL certificate is installed and valid.
- 🔗 Update all internal links to use
https://
. - 🧼 Clear cache & cookies for accurate testing.
- 🔁 Test the redirect using https://httpstatus.io
✅ Conclusion
Redirecting HTTP to HTTPS is a small step with huge rewards. It secures your site, protects your users, and improves your Google search ranking. Whether you use Apache, Nginx, Cloudflare, or cPanel—implementing HTTPS redirection is a must in 2025.
Ready to secure your site? Let GwHosting help with free SSL certificates and one-click HTTPS setup for all hosting plans!