How to Set Up an SSL Certificate & Force HTTPS Redirection

A website needs more than reliable hosting and a working domain name to protect visitors and handle connections securely. It also needs a valid SSL/TLS certificate and a configuration that directs visitors to the secure version of the website. Without these measures, visitors may encounter browser security warnings, and information sent over an unencrypted HTTP connection may be exposed to interception.

Setting up an SSL certificate and forcing HTTPS redirection are two related but separate tasks. The certificate enables encrypted connections, while the redirect sends visitors who enter an HTTP address to the HTTPS version of the same page.

Most modern hosting providers offer SSL certificate installation through their control panels. Website owners who manage their own servers can configure certificates through tools such as Certbot, Apache, or NGINX. Websites using a content delivery network (CDN) may also have additional SSL/TLS settings to configure.

This guide explains how to install an SSL certificate, redirect HTTP traffic to HTTPS, check that the configuration works, and resolve common problems.

What Is an SSL Certificate, and Why Does Your Website Need One?

SSL stands for Secure Sockets Layer, an older security protocol that has been superseded by Transport Layer Security (TLS). The term SSL certificate remains widely used, but modern HTTPS connections rely on TLS.

An SSL/TLS certificate helps a browser verify the identity of a website and establish an encrypted connection. This protects information transmitted between the visitor and the server against interception and unauthorized modification while it travels across the network.

HTTPS is particularly important for websites that handle login credentials, contact forms, customer information, online payments, or account sessions. It also protects ordinary browsing activity from certain forms of network surveillance and interference.

A valid certificate alone does not make an entire website secure. Website owners must also maintain their software, protect administrator accounts, use appropriate access controls, and secure their hosting environments.

There are practical reasons to implement HTTPS correctly:

  • Protect visitor information: HTTPS encrypts data transmitted between the browser and the website.

  • Build visitor confidence: Browsers identify HTTPS connections differently from unsecured HTTP connections.

  • Protect website sessions: Encrypted connections help prevent attackers on the network from reading session information transmitted without encryption.

  • Support modern web security: HTTPS is a foundation for many browser security features and web technologies.

  • Avoid insecure resource warnings: Serving a page over HTTPS while loading certain resources over HTTP can trigger mixed-content warnings or cause browsers to block those resources.

Google has also documented HTTPS as a ranking signal. However, installing a certificate does not guarantee higher search rankings. Its primary purpose is to secure connections.

Step 1: Check Your Hosting Environment

Before installing a certificate, identify how your website is hosted. The correct installation method depends on your hosting provider, server software, and whether another service handles HTTPS connections before traffic reaches your server.

There are three common situations.

Shared hosting: If your website runs on shared hosting, check the hosting control panel for an SSL/TLS or security section. Many providers offer automatic certificate installation and renewal.

Virtual private server or dedicated server: If you manage your own server, you may need to obtain a certificate, configure the web server, and arrange certificate renewal.

CDN or reverse proxy: If a service such as Cloudflare handles incoming website traffic, you must configure the certificate and encryption settings for the relevant connections. A certificate between visitors and the CDN does not automatically prove that the connection between the CDN and your origin server is encrypted.

Also, confirm that your domain points to the correct hosting environment. Check the DNS records for the root domain and any subdomains that the website uses.

Decide whether your preferred website address includes www. For example, you might use https://example.com or https://www.example.com. Choose one as the canonical address and configure the other to redirect to it.

Replace example.com in the examples throughout this guide with your actual domain name.

Step 2: Obtain an SSL/TLS Certificate

You generally have three options for obtaining a certificate: automatic installation through your hosting provider, a free certificate issued by a recognized certificate authority, or a paid certificate purchased through a certificate provider.

Option 1: Use Your Hosting Provider's SSL Tool

This is usually the simplest approach for website owners using shared hosting.

  1. Sign in to your hosting account.

  2. Open the control panel.

  3. Locate the SSL/TLS or certificate management section.

  4. Select the domain you want to secure.

  5. Enable the available SSL certificate or automatic certificate management feature.

  6. Wait for the installation process to complete.

  7. Confirm that the certificate covers the correct domain names.

On supported cPanel installations, the AutoSSL feature can manage certificate issuance and renewal. The precise options depend on the hosting provider and server configuration.

Some providers install certificates automatically when a domain is added to an account. Others require the website owner to enable the feature or complete domain validation.

Option 2: Use Let's Encrypt

Let's Encrypt is a certificate authority that issues certificates at no charge. It supports automated certificate issuance and renewal.

For administrators who control their own servers, Certbot is one tool that can obtain and install certificates for supported web server configurations.

A common workflow on a supported Linux server is:

  1. Confirm that the domain resolves to the server.

  2. Confirm that the required network access and domain validation method are available.

  3. Install Certbot using the instructions for the server's operating system and web server.

  4. Request a certificate for the required domain names.

  5. Follow the installation prompts or configure the web server as directed.

  6. Test certificate renewal.

The exact Certbot command depends on the operating system, installation method, and web server. Consult the official Certbot instructions rather than copying a command intended for a different environment.

A certificate must be renewed before it expires. Configure automated renewal where supported and test the renewal process to confirm that it works.

Option 3: Purchase a Certificate

Some businesses purchase certificates to meet particular organizational requirements or obtain additional validation and support services.

Before buying one, determine whether the hosting provider already includes a suitable certificate. A paid certificate is not automatically more secure than a free certificate for ordinary HTTPS encryption. The appropriate choice depends on the website's requirements and the certificate's features.

Regardless of the option selected, confirm that the certificate is valid for the exact hostname visitors will use.

Step 3: Confirm That HTTPS Works

After installing the certificate, test the HTTPS address before forcing all traffic to use it.

Open your website using its HTTPS address:

https://example.com

Check that the page loads without a certificate warning. Then inspect the certificate information in your browser to confirm that it is valid for the domain and has not expired.

Test the www and non-www versions if both are configured to serve your website. For example:

  • https://example.com

  • https://www.example.com

If one address produces a certificate error, check whether the certificate covers that hostname and whether the web server is configured to serve the correct certificate.

If the site does not load over HTTPS, do not proceed with a forced redirect until the underlying problem has been resolved. Redirecting visitors to a broken HTTPS endpoint can make the entire website inaccessible.

Also, check that your server or hosting provider supports HTTPS connections on the appropriate port. A certificate may exist in the hosting account without being correctly installed on the server handling incoming requests.

Step 4: Force HTTPS Redirection

Once HTTPS works, configure the website to redirect HTTP requests to the secure address.

For example, a visitor entering:

http://example.com/about

should be redirected to:

https://example.com/about

A properly configured redirect preserves the requested page path. It should also preserve the query string when required by the application.

A permanent HTTP 301 redirect is commonly used when HTTPS is the intended long-term destination. Browsers and search engines can use this response to recognize the permanent move.

Choose one primary redirect location. Depending on your setup, this may be your hosting control panel, web server, application, or CDN. Configuring competing redirects across several layers can create unnecessary redirect hops or redirect loops.

Method A: Enable HTTPS Redirection in Your Hosting Control Panel

Some hosting providers offer a setting that forces HTTPS for a selected domain.

The general process is:

  1. Sign in to your hosting control panel.

  2. Open the domain management or security section.

  3. Find the HTTPS redirection setting.

  4. Enable the redirect for the domain.

  5. Save the configuration.

  6. Test the HTTP and HTTPS versions of the website.

The location and name of this setting vary by hosting provider. If the control panel does not offer it, use the appropriate server configuration or application-level method.

Do not enable the redirect until the HTTPS version has been tested successfully.

Method B: Redirect HTTP to HTTPS on Apache

Websites running Apache can use a permanent redirect in the HTTP virtual host configuration.

For example:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    Redirect permanent / https://example.com/
</VirtualHost>

This configuration redirects HTTP requests for the listed hostnames to the HTTPS address on example.com. The redirect also carries the requested path and query string forward.

The HTTPS virtual host must be configured separately to serve the website with the appropriate certificate.

If you do not have access to Apache's main configuration, your hosting provider may permit redirects through an .htaccess file. This requires the relevant Apache configuration and modules to support the directives used.

For a site where .htaccess rewriting is available, the following rule is one possible approach:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]

Place the rule in the appropriate context and check the existing rules before applying it. The example redirects to the non-www hostname, so adjust the destination if your preferred address includes www.

Do not add multiple competing HTTPS redirect rules without checking how the existing configuration handles them.

Method C: Redirect HTTP to HTTPS on NGINX

NGINX commonly uses a dedicated server block to redirect HTTP traffic.

For example:

server {
    listen 80;
    server_name example.com www.example.com;

    return 301 https://example.com$request_uri;
}

This configuration redirects requests received on port 80 to the HTTPS version of the same path and query string on example.com.

The server must also have a separate HTTPS configuration that listens on port 443 and specifies the certificate and private key.

A simplified example of the certificate directives is:

server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    # Add the site's existing application configuration here.
}

The file paths above are illustrative. Replace them with the actual certificate and private key paths on your server.

Before applying a configuration change, check the NGINX configuration syntax. After correcting any errors, reload the service using the procedure appropriate for your system.

Do not replace an existing production server configuration with these examples without accounting for the site's current application settings.

Method D: Force HTTPS on WordPress

WordPress websites need a working server-side HTTPS configuration as well as the correct website addresses.

First, confirm that the certificate is installed and the HTTPS version of the site loads correctly.

Next, open the WordPress dashboard and navigate to Settings > General.

Check the following fields:

  • WordPress Address (URL)

  • Site Address (URL)

If the website is intended to use HTTPS, both addresses should use the secure protocol. For example:

https://example.com

Save the changes if necessary, and confirm that you can still access the dashboard.

Then configure a permanent redirect through your hosting control panel, Apache, NGINX, or another suitable layer.

Changing the WordPress addresses alone does not guarantee that every HTTP request will redirect to HTTPS. Conversely, forcing a redirect before the server and application are correctly configured can cause access problems.

If WordPress runs behind a reverse proxy, load balancer, or CDN, ensure that it correctly recognises the original connection protocol. An incorrect proxy configuration can cause redirect loops.

Avoid installing multiple HTTPS redirect plugins that perform the same task. A single, correctly configured redirect is generally easier to maintain.

Method E: Force HTTPS Through Cloudflare

If your website uses Cloudflare, you can manage HTTPS redirection through its dashboard.

Before enabling a redirect, confirm that an appropriate edge certificate is active and that the SSL/TLS configuration is correct.

Cloudflare's Always Use HTTPS feature redirects visitor requests from HTTP to HTTPS.

The general process is:

  1. Sign in to Cloudflare.

  2. Select the relevant website.

  3. Open the SSL/TLS settings.

  4. Confirm that the required edge certificate is active.

  5. Check the SSL/TLS encryption mode and the configuration of the origin server.

  6. Enable Always Use HTTPS if the entire website is ready to use HTTPS.

  7. Test the website from both HTTP and HTTPS addresses.

Cloudflare distinguishes between the connection from the visitor to Cloudflare and the connection from Cloudflare to the origin server. Securing the first connection does not automatically mean the second connection is encrypted.

For a stronger end-to-end configuration, make sure the origin connection is also protected and that the selected encryption mode matches the origin server's certificate and configuration.

Avoid configuring conflicting redirects at Cloudflare and the origin server. If the browser reports too many redirects, inspect both layers and identify where the loop begins.

Step 5: Fix Mixed Content After Enabling HTTPS

Installing a certificate and redirecting HTTP traffic will not automatically update every link, image, script, stylesheet, or other resource referenced by your website.

Mixed content occurs when an HTTPS page requests certain resources over an unencrypted HTTP connection. Browsers may block active mixed content, such as scripts, or warn about insecure resources.

For example, the main page might load at:

https://example.com

But an image embedded in the page could still use:

http://example.com/images/banner.jpg

The page itself uses HTTPS, but the image reference still uses HTTP.

To resolve this problem:

  1. Inspect the browser's developer console for mixed-content warnings.

  2. Identify the resources still requested over HTTP.

  3. Update hard-coded URLs in your website's content, theme, templates, or application settings.

  4. Update external resource references where HTTPS is supported.

  5. Clear relevant application, caching, and CDN caches.

  6. Reload the page and check for remaining warnings.

For WordPress, review the website's stored content and configuration for outdated HTTP references. Back up the database before performing bulk URL replacements, particularly if the operation involves serialized data.

Some hosting and CDN services provide automatic HTTPS rewriting features. These can help with supported resources, but they should not replace fixing incorrect URLs in the website itself.

Also check embedded videos, third-party scripts, fonts, analytics integrations, and externally hosted images. A third-party resource that does not support HTTPS may require an alternative source.

Step 6: Test the Redirect and Certificate

Once the certificate, redirect, and internal URLs have been configured, test the website from several entry points.

Check the HTTP redirect. Enter an HTTP address directly into the browser. Confirm that it reaches the HTTPS version of the same page.

Check the destination. Confirm that the redirect uses your preferred hostname. If you use https://example.com as the canonical address, requests to http://www.example.com should eventually reach that address.

Check individual pages. Test the homepage, important landing pages, blog posts, contact pages, and other frequently accessed URLs.

Check the certificate. Confirm that the certificate is valid for the hostname, has not expired, and is being served correctly.

Check for redirect loops. Make sure the browser does not repeatedly redirect between HTTP and HTTPS or between different hostname variants.

Check the browser console. Look for certificate errors, mixed-content warnings, and failed network requests.

You can also use a terminal to inspect the HTTP response:

curl -I http://example.com

This sends a request and displays the response headers. For a working permanent redirect, you would normally expect an HTTP 301 status and a Location header pointing to the intended HTTPS address.

Next, inspect the HTTPS response:

curl -I https://example.com

This helps confirm that the HTTPS endpoint responds. However, a successful header response alone does not prove that every page, resource, or application function works correctly.

For additional verification, inspect the certificate using a browser or a suitable TLS diagnostic tool. Test certificate renewal separately rather than assuming it will work because the initial installation succeeded.

Common SSL Certificate and HTTPS Redirection Problems

Even a straightforward installation can fail when the certificate, DNS configuration, web server, or application settings do not match.

1. The Browser Reports an Invalid Certificate

Possible causes include an expired certificate, a hostname mismatch, an incomplete certificate chain, or the server presenting the wrong certificate.

Check the certificate details and confirm that the web server is using the intended certificate files. If a CDN or reverse proxy is involved, inspect the certificate presented at each relevant connection endpoint.

2. The Website Enters a Redirect Loop

A redirect loop occurs when the browser is repeatedly sent between URLs without reaching the requested page.

This can happen when several systems enforce HTTPS independently or when an application behind a proxy does not correctly recognize the original connection protocol.

Review the redirect rules at the hosting, web server, application, and CDN levels. Remove conflicting rules and ensure that the application correctly handles forwarded protocol information from a trusted proxy.

3. The Website Loads, but Some Resources Fail

This often indicates mixed content, incorrect resource URLs, or third-party resources that cannot be loaded securely.

Inspect the browser console, correct the affected URLs, and retest the page. Do not assume that a valid certificate means every resource on the page is secure.

4. HTTPS Works, but HTTP Remains Accessible

Installing a certificate does not automatically force all visitors to use HTTPS.

If the HTTP version remains accessible without redirecting, check whether the redirect is enabled at the correct layer and whether the relevant virtual host or domain is covered by the configuration.

Test the actual response rather than relying solely on the hosting dashboard's status indicator.

5. The Certificate Expires Unexpectedly

Certificates require renewal. Automated renewal can fail because of DNS changes, validation problems, expired account permissions, or changes to the server configuration.

Check the renewal system's logs, confirm that the domain can complete the required validation, and test renewal after correcting any errors.

For a production website, certificate monitoring is important because an expired certificate can prevent visitors from accessing the site without browser warnings.

Best Practices for Maintaining HTTPS

After completing the initial setup, maintain the configuration as part of your website's regular infrastructure management.

  • Enable automatic renewal: Use your hosting provider's certificate management feature or a properly configured renewal tool.

  • Keep a backup: Back up relevant server configuration files before changing redirect rules or certificate settings.

  • Use one canonical hostname: Decide whether the primary address includes www and redirect alternative versions consistently.

  • Avoid unnecessary redirect chains: Send visitors directly to the preferred HTTPS address rather than passing through several intermediate URLs.

  • Protect private keys: Restrict access to certificate private keys and keep them out of public directories and source repositories.

  • Monitor certificate validity: Check expiration dates and investigate renewal failures promptly.

  • Review CDN settings: If a CDN or reverse proxy handles HTTPS, confirm that both visitor-facing and origin-facing connections use the intended encryption settings.

  • Check after infrastructure changes: Retest HTTPS after changing hosting providers, DNS records, server software, or CDN configurations.

Consider HTTP Strict Transport Security (HSTS) only after HTTPS is working consistently across the relevant hostnames. HSTS instructs supporting browsers to use HTTPS for future connections. Incorrect configuration, particularly when applied to subdomains, can make affected sites inaccessible until the problem is resolved. It is not a substitute for a valid certificate or a properly configured server.

Conclusion

Setting up an SSL/TLS certificate and forcing HTTPS redirection are essential steps in maintaining a secure, reliable website.

The process begins with identifying the hosting environment, obtaining and installing a valid certificate, and confirming that HTTPS works. The next step is to redirect HTTP traffic to the preferred HTTPS address through the hosting control panel, web server, application, or CDN.

The remaining work involves correcting mixed-content references, testing redirects, checking certificate validity, and ensuring that automatic renewal functions correctly.

Website owners should select the method that matches their hosting environment instead of copying server rules without understanding the existing configuration. A shared hosting account may need only a few control panel settings, while a self-managed server may require changes to Apache or NGINX.

Once the configuration is working, regular monitoring helps prevent certificate expiration, broken redirects, and avoidable access problems. The result is a website that consistently serves visitors over HTTPS and maintains a more reliable foundation for its wider security and infrastructure requirements.

What is man, that thou art mindful of him? Psalm 8:4

Comments

Popular

How to Migrate WordPress to a Static Site Builder (Step-by-Step)