The technology behind switching to HTTPS is not difficult; the challenge lies in the sequence. Many people immediately configure forced redirection, resulting in a sudden outbreak of mixed content issues, backend login failures, and other problems, with no way back.
The core principle of the correct sequence is: First, make HTTPS available without forcing it. Once confirmed stable, then enable forced redirection.
Process Overview
| Step | Action | Affects Existing Access? |
|---|---|---|
| 1 | Apply and deploy certificate | No |
| 2 | HTTPS available, but no forced redirect | No |
| 3 | Handle mixed content | No |
| 4 | Update site URLs | No |
| 5 | Configure 301 forced redirect | Yes |
| 6 | Update sitemap and canonical tags | No |
| 7 | Enable HSTS (Optional, do last) | Yes |
Steps 1–2: Deploy Certificate Without Forced Redirect
server {
listen 80;
server_name example.com www.example.com;
# Do not redirect yet; keep HTTP accessible
root /var/www/html;
index index.php;
}
server {
listen 443 ssl http2;
server_name example.com www.example.com;
ssl_certificate /etc/nginx/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
root /var/www/html;
index index.php;
}
nginx -t && nginx -s reload
# Verify HTTPS availability
curl -I https://example.com/
openssl s_client -connect example.com:443 -servername example.com
-verify_return_error </dev/null 2>/dev/null | grep -i 'verify return'
During this phase, both protocols coexist. Even if HTTPS encounters issues, users can still access the site via HTTP. This is the most critical safety net in the entire process.
Step 3: Handle Mixed Content
# Find http resources in pages
curl -s https://example.com/ | grep -oE '(src|href)="http://[^"]+"' | sort -u
# WordPress: Replace in database (Use WP-CLI, do NOT use direct SQL REPLACE)
wp search-replace 'http://example.com' 'https://example.com' --all-tables --dry-run
wp search-replace 'http://example.com' 'https://example.com' --all-tables
# Hardcoded links in themes/plugins
grep -rn "http://example.com" /var/www/html/wp-content/themes/ --include='*.php' | head
This step must be completed before enabling forced redirection. Once HTTPS is forced, browsers will block http resources on the page, resulting in broken functionality for users.
Step 4: Update Site URLs
wp option update home 'https://example.com'
wp option update siteurl 'https://example.com'
# Confirm
wp option get home
wp option get siteurl
Step 5: Configure 301 Redirect
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri; # Preserve path
}
nginx -t && nginx -s reload
# Verify (Pages with paths should redirect to corresponding HTTPS paths)
curl -I http://example.com/about/ | grep -i location
# Should result in https://example.com/about/
Step 6: SEO Related Tasks
| Item | Action Required |
|---|---|
| Canonical | Point to HTTPS version |
| Sitemap | Change all URLs to HTTPS |
| robots.txt | Update Sitemap URL if present |
| Internal Links | Already handled by database replacement |
| External Links | Out of control; rely on 301 redirects |
# Verify URL protocol in sitemap
curl -s https://example.com/sitemap.xml | grep -oE '<loc>[^<]+' | head -5
301 redirects are key to preserving link equity from old links. As long as the 301 preserves the path, external HTTP links will automatically redirect to the corresponding HTTPS pages.
Step 7: HSTS (Last Step, Think Carefully)
# Start with a short max-age for testing
add_header Strict-Transport-Security "max-age=300" always;
# Extend after confirming everything works
add_header Strict-Transport-Security "max-age=31536000" always;
HSTS forces browsers to use HTTPS within the validity period, with no way back. Therefore, start with a short value for testing. Only extend it after confirming that the entire site (including all subdomains) supports HTTPS.
Rollback Options
Between steps 1–4, you can rollback at any time (simply comment out the 443 server block). Once Step 5 (forced redirect) is executed, rollback becomes complex—because user browsers will be guided by the 301 redirect.
Therefore: Take your time with the first four steps. Ensure everything is verified before proceeding to Step 5.
Decision Tree
Migrate to HTTPS
├─ ① Deploy certificate (fullchain, not just cert)
├─ ② HTTPS available but not forced ← Leave room for rollback, don't skip steps
├─ ③ Handle mixed content (database + hardcoded template links)
│ └─ Use wp search-replace, do NOT use SQL REPLACE
├─ ④ Update home / siteurl
├─ ⑤ Configure 301 (preserve $request_uri) ← Impact on access starts here
├─ ⑥ Sync sitemap / canonical / robots
└─ ⑦ HSTS (Start short, extend later after confirming full site availability)
If Issues Arise
├─ Before Step 5 → Comment out the 443 block to rollback directly
└─ After Step 5 → Need to remove 301, but previously visited users may be affected by cache
Scenario Analysis: Indexing Dropped by Half After Switching to HTTPS
Symptom: The site switched from plaintext to encrypted access.
Full-site redirect configuration is complete, and the certificate is normal, but indexing volume and traffic continue to decline.
- Check if the redirect is “whether it exists” or “where it goes” → Visiting old addresses does redirect,
but the final destination is the homepage instead of the specific page. - Confirm why this is fatal → Deep URLs all point to the homepage,
which is treated as soft 404s, causing the accumulated value of those pages to become invalid. - Check for remaining plaintext references in internal links → There are still many hardcoded plaintext addresses in post content and templates.
These will not change automatically just because a redirect is configured. - Verify if canonical and sitemap are synchronized → Both still point to the old format,
sending inconsistent signals to search engines compared to reality. - Complete three things: Path-preserving redirects, content replacement, and consistent signal maps → All three are indispensable.
- Maintain rollback capability for a period → Do not immediately revoke access to the old format.
Observe for a while before fully closing it off.
# ① Check if redirect preserves path (Most Critical)
curl -sSL -o /dev/null -w 'Final=%{url_effective} Redirects:%{num_redirects} timesn' http://example.com/deep/page
# ② Check for remaining plaintext references
curl -s https://example.com/ | grep -oE 'src="http://|href="http://' | head
mysqldump dbname | grep -o 'src="http://[^"]*"' | wc -l
# ③ Check consistency between map and actual content
curl -s https://example.com/sitemap.xml | grep -o '[^<]*' | head -5
# ④ Replacement must understand serialized formats; do not use plain text replacement
wp search-replace 'http://example.com' 'https://example.com' --dry-run --report-changed-only
Root Cause: The switch only addressed the “access entry” layer.
The hardcoded resource references inside the site, the target addresses of redirects, and the signals sent to search engines were not updated synchronously.
Two Key Takeaways:
- A valid migration must satisfy three conditions simultaneously: Path-level redirects, internal reference replacement, and synchronization of sitemaps and canonical tags.
Doing only redirects effectively zeroes out the value of all deep URLs at once. - Verification must test deep URLs, not just the homepage.
The homepage will look normal under any configuration; only specific pages can reveal whether paths are being preserved.
8 Common Pitfalls
- Forcing redirect immediately: Problems are exposed directly to users.
- Ignoring mixed content: Images and scripts fail to load.
- Using SQL REPLACE: Corrupts serialized data.
- 301 redirecting to homepage: Loses path structure and link equity.
- Sitemap not updated: Search engines still crawl HTTP.
- Enabling long-duration HSTS too early: No way back if issues arise.
- Using cert instead of fullchain: Some clients report incomplete chain errors.
- Failing to verify after switching: Must use
-verify_return_errorto check.
Real Customer Feedback (From Cloud Market Reviews and Consultations for Similar Products)
The following excerpts are taken from real buyer reviews and consultations for similar operations services on Alibaba Cloud / Tencent Cloud / Huawei Cloud marketplaces (Service providers include our store and peers, provided for reference only, not fictional tickets from this site):
28***05 2021-08-02 5.0 Skilled Technology | Affordable Price | Perfect After-sales (User did not fill in review content) 10***31 2021-08-01 5.0 Secure & Reliable | Perfect After-sales | Affordable Price ok 10***31 2021-08-01 5.0 Comprehensive Features | Affordable Price | Patient & Professional Reasonable price, fast configuration 28***05 2021-07-30 5.0 On-time Delivery | Patient & Professional | Perfect After-sales (User did not fill in review content) 28***05 2021-07-29 5.0 Affordable Price (User did not fill in review content)
10***79 2024-09-08 5.0 On-time Delivery | Secure & Reliable | Skilled Technology (User did not fill in review content)
10***58 2025-04-26 5.0 On-time Delivery | Secure & Reliable | Perfect After-sales (User did not fill in review content) 10***16 2023-06-16 5.0 Comprehensive Features | Affordable Price | On-time Delivery Professional SSL service on the cloud market 10***65 2022-12-18 5.0 Comprehensive Features | Affordable Price | Skilled Technology Handled promptly, configured right when it expired. 10***31 2022-12-08 5.0 Affordable Price | Skilled Technology | Perfect After-sales Easy to use, timely configuration 10***31 2022-12-07 5.0 Affordable Price | Perfect After-sales | Comprehensive Features Fast handling, easy to use