↪️
blog.cat.ssl

Redirecting HTTP to HTTPS correctly: .htaccess, Nginx and WordPress

20.11.2026
← All articles

Installing an SSL certificate does not make a site open securely by itself. When someone types example.uz or follows an old link, the browser often still requests plain http://. Unless the server redirects that request, the page loads unencrypted and the address bar says "Not secure". So the first job after SSL is a correct redirect from HTTP to HTTPS.

What a correct redirect looks like

It is permanent (301, not 302), so search engines treat the HTTPS address as the real one. It keeps the path, so http://example.uz/katalog/divan lands on https://example.uz/katalog/divan, not the home page. And it takes one hop: chains like HTTP to www to HTTPS to non-www slow pages down and invite mistakes.

Apache and .htaccess

On shared hosting, including ISPmanager servers, Apache usually reads rules from .htaccess in the site root:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If non-www is your main address, combine both redirects into one rule so every variant arrives in a single hop:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.uz%{REQUEST_URI} [L,R=301]

Put these at the top, before the CMS rules, and keep a backup copy: one typo can turn the whole site into a 500 error.

Nginx

server {
    listen 80;
    server_name example.uz www.example.uz;
    return 301 https://example.uz$request_uri;
}

Then test and reload with sudo nginx -t && sudo systemctl reload nginx. Let's Encrypt validation follows redirects, so you normally do not need to exempt /.well-known/acme-challenge/, as long as the redirect does not lead to another domain.

ERR_TOO_MANY_REDIRECTS

A redirect loop usually comes from two conflicting rules, for example .htaccess sending visitors to non-www while the CMS site address uses www and sends them back. Another cause is a proxy in front of the site: the server sees every request as HTTP and keeps redirecting, so you need to check the X-Forwarded-Proto header instead of %{HTTPS}. Trace each hop with:

curl -sIL http://www.example.uz | grep -iE "^(HTTP|location)"

A healthy result is one 301 followed by a 200. If you see two or three 301 responses in a row, look for rules that could be merged; if the same two addresses alternate endlessly, two places in your setup disagree about the main address and one of them has to be changed.

Example: a dental clinic on WordPress

A dental clinic in Namangan added SSL to misol.uz; the developer installed a redirect plugin and also added an .htaccess rule, while WordPress still had http://www.misol.uz as its address. The site stopped loading with ERR_TOO_MANY_REDIRECTS. The fix: remove the plugin, keep the combined rule above, and switch WordPress to HTTPS:

wp option update home 'https://misol.uz'
wp option update siteurl 'https://misol.uz'
wp search-replace 'http://www.misol.uz' 'https://misol.uz' --skip-columns=guid

Back up the database before the last command, and preview it first with --dry-run.

Mixed content comes next

Even with a working redirect, the padlock may show a warning because images, scripts or fonts still load over http://. The browser's developer Console lists them; switch them to HTTPS or relative paths, since browsers may block insecure scripts outright. On sayt.uz hosting, Let's Encrypt certificates are free and renew automatically, and the redirect can be enabled in the hosting panel's site settings or in .htaccess. Use only one of those mechanisms, because two at once is the classic cause of a loop.

Related articles

📧 SSL for mail.domain.uz: Fixing the Outlook Certificate Warning ⏳ Let's Encrypt Rate Limits: Fixing "too many certificates" 📜 Certificate Transparency: How Public Logs of SSL Certificates Work 🏢 SSL for internal (intranet) sites: how to secure office systems
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓