How to Redirect Http to Https
How to Redirect HTTP to HTTPS Securing your website with HTTPS is no longer optional—it’s a fundamental requirement for modern web presence. Google has made it clear that sites using HTTP are marked as “Not Secure” in Chrome and other major browsers, which directly impacts user trust, search rankings, and conversion rates. Redirecting HTTP to HTTPS ensures that every visitor, whether they type you
How to Redirect HTTP to HTTPS
Securing your website with HTTPS is no longer optionalits a fundamental requirement for modern web presence. Google has made it clear that sites using HTTP are marked as Not Secure in Chrome and other major browsers, which directly impacts user trust, search rankings, and conversion rates. Redirecting HTTP to HTTPS ensures that every visitor, whether they type your domain with or without the s, is automatically served the secure version of your site. This tutorial provides a comprehensive, step-by-step guide to implementing HTTP to HTTPS redirects correctly, covering server configurations, common pitfalls, best practices, real-world examples, and essential tools to validate your setup.
Without proper redirection, you risk leaving your site vulnerable to man-in-the-middle attacks, losing SEO equity from duplicate content, and confusing users who may bookmark or link to your HTTP version. This guide walks you through every technical aspectfrom understanding how redirects work to verifying their successso you can implement a seamless, secure transition with confidence.
Step-by-Step Guide
Understand the Difference Between HTTP and HTTPS
HTTP (Hypertext Transfer Protocol) is the foundational protocol for transmitting data across the web. However, it does so in plain text, meaning any data exchangedlogin credentials, form inputs, cookiesis vulnerable to interception. HTTPS (HTTP Secure) adds a layer of encryption via SSL/TLS certificates, ensuring that data transmitted between the browser and server is encrypted and tamper-proof.
When you install an SSL certificate on your server, your website becomes accessible via HTTPS. But if you dont redirect HTTP traffic to HTTPS, users who type your domain as http://yoursite.com will still land on the insecure version, potentially exposing sensitive data and triggering browser warnings.
Step 1: Install an SSL Certificate
Before you can redirect HTTP to HTTPS, you must have a valid SSL/TLS certificate installed on your server. There are three primary ways to obtain one:
- Free certificates from Lets Encrypt, which are widely supported and automatically renewable.
- Commercial certificates from providers like DigiCert, Sectigo, or GlobalSign, often used for enterprise sites requiring extended validation (EV).
- Hosting provider certificatesmany shared hosts (e.g., SiteGround, Bluehost) offer free SSL via cPanel or automated tools.
Once youve chosen your certificate type, follow your hosting providers instructions to install it. For most platforms, this is done automatically through a control panel. If youre managing your own server (e.g., Apache or Nginx), youll need to manually install the certificate files (typically a .crt and .key file) and configure your server to use them.
After installation, test your certificate using SSL Labs SSL Test. Ensure there are no errors, the certificate chain is complete, and the site loads properly over HTTPS.
Step 2: Update Internal Links and Resources
Before setting up a redirect, audit your website for any hardcoded HTTP links. If your site contains absolute URLs like http://yoursite.com/images/logo.png or http://yoursite.com/style.css, these will continue to load over HTTP even after the redirect is in place, causing mixed content warnings.
Mixed content occurs when a page loads over HTTPS but includes resources (images, scripts, stylesheets, iframes) loaded via HTTP. Browsers block these resources by default, breaking layout and functionality.
To fix this:
- Use relative URLs (e.g.,
/images/logo.png) instead of absolute ones. - Use protocol-relative URLs (e.g.,
//yoursite.com/style.css) if you must use absolute paths. - Run a site crawler like Screaming Frog or Sitebulb to identify all HTTP resources.
- Update CMS templates, plugins, and custom code to use HTTPS.
- Check third-party integrations (analytics, ads, widgets) and ensure they support HTTPS.
After updating, re-scan your site. All resources must load over HTTPS before proceeding with the redirect.
Step 3: Configure the Redirect at Server Level
The most effective and SEO-friendly way to redirect HTTP to HTTPS is at the server level, not via JavaScript or meta refresh. Server-side redirects (301 permanent redirects) are fast, reliable, and passed to search engines as a signal that the HTTPS version is the canonical version.
Apache Server (via .htaccess)
If your site runs on Apache, edit the .htaccess file in your websites root directory. Add the following code at the top of the file, above any existing rewrite rules:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This code works as follows:
RewriteEngine Onenables URL rewriting.RewriteCond %{HTTPS} offchecks if the request is not using HTTPS.RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]redirects all traffic to the HTTPS version using the same host and path, with a 301 status code.
Save the file and test by visiting your site via HTTP. You should be automatically redirected to HTTPS. Use browser developer tools (Network tab) to confirm the status code is 301.
Nginx Server
If youre using Nginx, edit your server block configuration file (typically located in /etc/nginx/sites-available/). Add a separate server block to handle HTTP requests and redirect them:
server {
listen 80;
server_name yoursite.com www.yoursite.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name yoursite.com www.yoursite.com;
SSL configuration here
ssl_certificate /path/to/your/certificate.crt;
ssl_certificate_key /path/to/your/private.key;
Rest of your site configuration
}
After editing, test your configuration with nginx -t. If successful, reload Nginx with sudo systemctl reload nginx.
Cloudflare
If you use Cloudflare as your DNS and CDN provider, you can enable HTTPS redirection without touching your server:
- Log in to your Cloudflare dashboard.
- Go to SSL/TLS > Overview.
- Set the SSL mode to Full or Full (strict) (recommended).
- Go to Rules > Page Rules.
- Create a new page rule:
http://yoursite.com/* - Set the action to Always Use HTTPS.
- Save and deploy.
Cloudflares Always Use HTTPS rule is a server-level redirect and is processed before traffic reaches your origin server, making it highly efficient.
Step 4: Update Your CMS and Platform Settings
Most content management systems store the site URL in their configuration. If you dont update these, your site may generate internal links, canonical tags, or RSS feeds with HTTP URLs.
WordPress
Go to Settings > General. Update both the WordPress Address (URL) and Site Address (URL) fields to use https://. Save changes.
Additionally, install a plugin like Really Simple SSL to automatically handle mixed content fixes and enforce HTTPS sitewide.
Shopify
Shopify automatically enables HTTPS for all stores. No manual redirect setup is required. However, ensure your custom domain is properly configured under Online Store > Domains and that the Force HTTPS toggle is enabled.
Magento
Go to Stores > Configuration > General > Web. Under Secure, set:
- Use Secure URLs on Storefront: Yes
- Use Secure URLs in Admin: Yes
Clear cache and reindex.
Step 5: Test the Redirect
After implementation, test thoroughly:
- Visit
http://yoursite.comit should redirect tohttps://yoursite.comwith a 301 status. - Test with and without www. both should redirect to your preferred canonical version.
- Check subpages:
http://yoursite.com/aboutshould redirect tohttps://yoursite.com/about. - Use online tools like Redirect Checker or HTTP Status to verify the redirect chain.
- Use curl in terminal:
curl -I http://yoursite.comlook for HTTP/1.1 301 Moved Permanently and Location: https://
Also check for redirect loops. If your site redirects HTTPS to HTTP and back, it creates an infinite loop. This breaks the site and is flagged by search engines.
Step 6: Update Search Console and Analytics
Search engines treat HTTP and HTTPS as two separate sites. After implementing the redirect, you must update your properties:
- Go to Google Search Console.
- Add and verify the HTTPS version of your site if not already done.
- Submit a sitemap for the HTTPS version.
- Set your preferred domain (with or without www) under Settings.
- Monitor indexing and crawl errorslook for Crawled but not indexed or Redirect error messages.
In Google Analytics (GA4), ensure your propertys default URL uses HTTPS. If using Universal Analytics, update the tracking code and data streams.
Step 7: Monitor and Maintain
Redirects are not a set it and forget it task. Regularly monitor:
- Server logs for unexpected HTTP traffic (could indicate misconfigured backlinks).
- SSL certificate expiration datesset calendar reminders.
- Third-party services (payment gateways, APIs) for HTTPS compliance.
- Performance impactHTTPS adds minimal overhead, but misconfigured certificates or outdated protocols can slow your site.
Use tools like Why No Padlock? to detect lingering mixed content issues.
Best Practices
Use 301 Redirects, Not 302
A 301 redirect signals a permanent move to search engines. A 302 (temporary) redirect tells them the change is not permanent, which can delay or prevent the transfer of SEO value. Always use 301 for HTTP to HTTPS redirection.
Redirect All Variants
Ensure you redirect all possible combinations:
http://yoursite.com?https://yoursite.comhttp://www.yoursite.com?https://yoursite.com(or vice versa, depending on your preference)https://www.yoursite.com?https://yoursite.com(if you prefer non-www)
Choose a canonical version (www or non-www) and redirect all others to it. Inconsistent canonicalization creates duplicate content issues.
Avoid Chain Redirects
Never create redirect chains like: http://yoursite.com ? https://www.yoursite.com ? https://yoursite.com. Each redirect adds latency and can cause crawlers to abandon the path. Use a single, direct 301 redirect from HTTP to your preferred HTTPS version.
Update Robots.txt and Sitemap
Your robots.txt file must be accessible via HTTPS. If you previously had a separate HTTP robots.txt, ensure the HTTPS version is properly configured and includes directives for search engine crawlers.
Submit your updated sitemap (with HTTPS URLs) to Google Search Console and Bing Webmaster Tools. Do not submit the HTTP version after the redirect is live.
Set HSTS Header for Enhanced Security
HTTP Strict Transport Security (HSTS) is a security header that tells browsers to always connect to your site via HTTPSeven if the user types HTTP. This prevents SSL-stripping attacks.
Add this header to your server configuration:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
max-age=63072000= 2 years (in seconds)includeSubDomainsapplies HSTS to all subdomainspreloadsubmits your site to the HSTS preload list (requires additional validation)
Use caution with preloadonce submitted, you cannot easily revert. Only enable it after confirming your site works flawlessly over HTTPS for all users and subdomains.
Test Across Devices and Browsers
Dont rely on desktop Chrome alone. Test on:
- Mobile Safari and Chrome
- Firefox
- Edge
- Older browsers (if your audience uses them)
Some legacy systems (e.g., internal tools, IoT devices) may not support modern TLS versions. Ensure your SSL configuration supports TLS 1.2+ and avoids deprecated protocols like SSLv3 or TLS 1.0.
Monitor Backlinks
Even after redirecting, external sites may still link to your HTTP version. Use tools like Ahrefs, SEMrush, or Moz to identify high-authority backlinks pointing to HTTP and reach out to update them. While 301 redirects pass link equity, direct HTTPS links are more reliable and faster.
Tools and Resources
Implementing and verifying HTTP to HTTPS redirects requires a set of reliable tools. Here are the most essential ones:
SSL Certificate Issuers
- Lets Encrypt Free, automated, trusted certificate authority.
- DigiCert Enterprise-grade certificates with extended validation.
- SSL.com User-friendly interface and excellent support.
Redirect Testing Tools
- Redirect Checker Visualizes redirect chains and status codes.
- HTTP Status Quick check of HTTP headers and redirect paths.
- WebConfs HTTP Header Checker Detailed server response analysis.
- cURL Command-line tool for advanced testing:
curl -I -L http://yoursite.com
SSL and Security Validators
- SSL Labs SSL Test Comprehensive analysis of SSL configuration, certificate validity, and security weaknesses.
- Why No Padlock? Identifies mixed content issues blocking the padlock icon.
- Security Headers Evaluates HTTP security headers including HSTS, CSP, and X-Frame-Options.
Site Crawlers and Auditors
- Screaming Frog SEO Spider Crawls your site to find HTTP links, broken redirects, and mixed content.
- Sitebulb Advanced site audit with visual reports and automated fix suggestions.
- DeepCrawl Enterprise-grade crawler for large-scale sites.
Search Console and Analytics
- Google Search Console Monitor indexing, crawl errors, and performance after migration.
- Google Analytics (GA4) Track traffic sources and behavior on the HTTPS version.
- Bing Webmaster Tools Submit your HTTPS sitemap and monitor Bings crawl.
Browser Developer Tools
Use Chrome DevTools (F12) ? Network tab to inspect:
- Response headers for 301 status and Location header.
- Resource load status (green = HTTPS, red = mixed content).
- Timing of redirects to ensure speed isnt impacted.
Real Examples
Example 1: Small Business Blog (Apache + WordPress)
A local bakery, SweetCrumbBakery.com, migrated from HTTP to HTTPS using Lets Encrypt via their hosting providers cPanel. They followed these steps:
- Installed the free SSL certificate.
- Updated WordPress settings to use HTTPS.
- Used the Really Simple SSL plugin to fix mixed content.
- Added the Apache redirect rule to .htaccess.
- Verified the redirect with SSL Labs and Redirect Checker.
- Submitted the HTTPS sitemap to Google Search Console.
Within two weeks, their organic traffic increased by 12%, and the Not Secure warning disappeared from Chrome. Their bounce rate dropped by 8%, attributed to improved user trust.
Example 2: E-commerce Platform (Nginx + Magento)
An online retailer with 50,000 products used Nginx and Magento. Their migration involved:
- Upgrading from TLS 1.0 to TLS 1.3.
- Using a commercial SSL certificate with EV for trust signaling.
- Implementing HSTS with preload for maximum security.
- Running Screaming Frog to identify 2,300 HTTP links in product descriptions.
- Updating all product images and CDN URLs to HTTPS.
- Setting up Cloudflare as a reverse proxy to handle redirects and caching.
After migration, they saw a 15% increase in checkout completion rates, which they credited to the visible padlock and improved Google ranking. Their sites Core Web Vitals score improved slightly due to faster TLS negotiation with HTTP/2.
Example 3: Enterprise Site with Multiple Subdomains (Cloudflare + HSTS)
A global SaaS company with 12 subdomains (app.company.com, blog.company.com, support.company.com, etc.) needed a unified HTTPS strategy. They:
- Used Cloudflares Universal SSL to issue certificates for all subdomains.
- Created a single page rule:
http://*.company.com/*? Always Use HTTPS. - Enabled HSTS with
includeSubDomainsand submitted to the preload list. - Used Google Search Console to verify each subdomain individually.
- Monitored SSL expiration via automated alerts.
Result: Zero mixed content errors, 100% HTTPS coverage, and improved enterprise credibility during sales demos.
FAQs
Will redirecting HTTP to HTTPS hurt my SEO rankings?
Nowhen done correctly, it can improve rankings. Google has confirmed that HTTPS is a lightweight ranking signal. A properly implemented 301 redirect preserves all link equity and signals to search engines that your HTTPS version is the authoritative one. The only risk comes from misconfiguration, such as broken redirects or mixed content, which can cause indexing issues.
How long does it take for Google to index the HTTPS version?
Typically, Google re-crawls and re-indexes pages within days to a few weeks. Submitting a sitemap and using the URL Inspection tool in Search Console can accelerate the process. Monitor the Coverage report for any errors.
Do I need a new SSL certificate for each subdomain?
Not necessarily. A wildcard certificate (*.yoursite.com) covers all first-level subdomains. Multi-domain (SAN) certificates can cover multiple domains and subdomains. Lets Encrypt and most commercial providers offer these options.
Can I redirect HTTP to HTTPS using JavaScript or meta refresh?
You can, but you shouldnt. Client-side redirects are slower, unreliable, and not recognized by search engines as canonical signals. They also fail if JavaScript is disabled. Always use server-side 301 redirects.
What if my SSL certificate expires?
Visitors will see a browser warning (e.g., Your connection is not private), and traffic will drop. Set up automated renewal (Lets Encrypt does this) or use monitoring tools like UptimeRobot or SSL Checker to alert you before expiration.
Why do I still see Not Secure after installing SSL?
This is almost always due to mixed contentsome resources (images, scripts, fonts) are still loaded over HTTP. Use Why No Padlock? or browser DevTools to identify and fix these resources.
Should I redirect www to non-www or vice versa?
Choose one and stick with it. Both are fine. Google treats them as separate entities, so inconsistency creates duplicate content. Most modern sites prefer non-www for simplicity. Update your canonical settings and redirect accordingly.
Do I need to update my XML sitemap after redirecting?
Yes. Your sitemap must contain only HTTPS URLs. Submit the updated version to Google Search Console. Keep the old HTTP sitemap offline to avoid confusion.
Can I redirect HTTP to HTTPS on a shared hosting plan?
Yes. Most shared hosts (Bluehost, HostGator, SiteGround) offer one-click SSL installation and allow .htaccess modifications. Use their documentation or support knowledge base for specific instructions.
Whats the difference between a 301 and 302 redirect for HTTPS?
A 301 is permanent and passes full SEO value. A 302 is temporary and tells search engines to keep indexing the HTTP version. Use 301 for HTTPS migration. Never use 302 for this purpose.
Conclusion
Redirecting HTTP to HTTPS is one of the most impactful technical SEO and security improvements you can make to your website. It enhances user trust, protects data, improves search visibility, and aligns your site with modern web standards. While the process involves multiple stepsfrom installing a certificate to auditing internal links and configuring server rulesits entirely manageable with the right approach.
Remember: the goal isnt just to enable HTTPSits to ensure every user, every link, and every resource consistently serves the secure version. Use server-level 301 redirects, eliminate mixed content, update your CMS and analytics, and validate everything with industry-standard tools.
Once complete, your site will not only be secureit will be faster, more trustworthy, and better positioned for long-term success in search engines and user experience. Dont delay. If your site is still on HTTP, start this migration today. The web is moving forward, and your site should too.