WWW & HTTPS Redirect Generator
Generate the canonical www/non-www and HTTP-to-HTTPS redirect rules so you serve one clean URL version to Google.
What does it mean to force https redirect?
To force https redirect means telling every browser and search crawler that your site has exactly one correct address, and that it always loads over the secure HTTPS protocol. When you force https redirect, insecure http:// requests get sent to the https:// version with a 301 redirect. A force https redirect also fixes the www versus non-www split, so one canonical domain wins.
Here is the problem the redirect solves. A single web page can technically be reached at four different addresses: http://example.com, http://www.example.com, https://www.example.com, and https://example.com. To a human they look identical. To Google and to Bing they are four separate URLs that happen to serve the same content. That is duplicate content, and it quietly wastes crawl budget, splits your link signals, and confuses which version should rank.
A force https redirect collapses those four doorways into one. You decide which address is your true home, you point every other variant at it with a permanent redirect, and you make sure the destination is always encrypted. From that moment, visitors, browsers, and crawlers all agree on a single canonical domain, and every ranking signal you earn flows to the same URL instead of leaking across duplicates.
This is not an optional polish step. Since Google began treating HTTPS as a lightweight ranking signal and Chrome started flagging plain http:// pages as "Not Secure," a clean redirect to the secure canonical is table stakes for any site that wants to be trusted and indexed properly. The good news is that the fix lives in one small block of server configuration, and this generator writes it for you.
How to use the WWW and HTTPS Redirect Generator
The generator turns a few simple choices into ready-to-paste server rules. You pick your canonical shape, choose your server software, and copy the output. There is nothing to install and nothing to memorize. In under a minute you get a correct, safe force https redirect block tailored to Apache or Nginx.
- Enter your domain. Type your bare domain, for example example.com, without http or a trailing slash. The tool uses this to build the exact redirect target.
- Choose your canonical version. Decide whether your preferred address is www (www.example.com) or non-www (example.com). Either one is fine for SEO. What matters is that you pick one and stay consistent.
- Confirm HTTPS enforcement. Keep the force HTTPS option on so that every http:// request is upgraded to https://. This is the core of a force https redirect.
- Select your server type. Choose Apache if your host uses .htaccess, or Nginx if you edit server blocks. If you are unsure, most shared cPanel hosting is Apache and most VPS and cloud setups are Nginx.
- Copy the generated rules. The tool outputs a clean redirect block. Copy it into your .htaccess file (Apache) or your server block (Nginx).
- Deploy and test. Upload or reload the config, then visit all four URL variants to confirm each one lands on your single secure canonical with a 301 status.
Because the output is plain text configuration, you keep full control. You can read every line before you paste it, adjust the domain if you manage several sites, and version the file in git alongside the rest of your project.
Why a force https redirect matters for SEO
A force https redirect matters because it consolidates everything a search engine needs to rank you well: one address, one secure connection, and one place for link equity to gather. Without it, your authority is scattered across duplicate URLs, your snippets can show an insecure version, and browsers may warn visitors away before they ever read your page.
Break that down into the four benefits that actually move rankings and conversions.
It kills duplicate content across http, https, and www
When the same page answers on four addresses, search engines have to guess which one you want indexed. They usually pick a canonical on their own, but their guess may not match yours, and the guessing itself dilutes signals. A force https redirect removes the ambiguity. Every crawler that requests any variant is permanently sent to your chosen URL, so there is only ever one version to index. That is cleaner crawling, faster indexing of new content, and no wasted crawl budget on mirror URLs.
It consolidates link equity into one URL
Backlinks are votes. If some sites link to http://example.com, others to https://www.example.com, and a few to the bare https version, those votes get split across separate URLs. A 301 redirect passes the ranking value of a link from the old address to the new one, so pointing every variant at your canonical merges all of that authority into a single page. One strong URL almost always outranks the same content spread thin across four weak ones.
It delivers the security and trust signals Google rewards
HTTPS encrypts the connection between your visitor and your server, which protects form submissions, logins, and payment details. Google confirmed years ago that HTTPS is a ranking signal, and modern browsers actively label plain http:// pages as "Not Secure." Forcing HTTPS means no visitor ever sees that warning and no crawler indexes an insecure copy. You get the security signal and the trust signal at the same time.
It protects your Core Web Vitals and analytics accuracy
Redirect chains and mixed http and https traffic add latency and pollute your data. When everyone lands on one canonical over one protocol, your analytics stops splitting sessions between secure and insecure hostnames, and your speed metrics stop paying the tax of extra hops. A single, direct force https redirect keeps both your reporting and your performance honest.
Understanding the redirect rules
A force https redirect is really two decisions expressed as server rules: which hostname is canonical, and how permanent the redirect is. Get those two right and the configuration writes itself. Below is how to choose, followed by correct, copy-safe examples for both Apache and Nginx.
Choosing www versus non-www
Search engines do not favor www over non-www or the other way around, so this is purely your call. Non-www (example.com) looks shorter and more modern, which is why many brands prefer it. The www prefix has one technical edge: it lets you set cookies and use a CDN more flexibly at the DNS level, because you can point a subdomain with a CNAME. Whichever you choose, define it once and enforce it everywhere, including internal links, your sitemap, and your canonical tags.
301 versus 302: always use 301 here
A 301 redirect is permanent and tells search engines to transfer ranking signals to the destination and update their index. A 302 is temporary and instructs them to keep the original URL indexed. For canonicalization you always want a 301. A stray 302 on your www or HTTPS redirect can prevent link equity from passing and leave the wrong version in the index. Google documents this clearly in its guidance on 301 redirects for site moves and canonicalization.
Apache .htaccess rules
On Apache you place the rules in an .htaccess file in your site root, or in the main server config. The block below forces HTTPS and forces the non-www version. It uses mod_rewrite, documented in the official Apache mod_rewrite manual. Put these lines near the top, before any application rules such as a WordPress front controller.
RewriteEngine On
# Force HTTPS and force non-www (example.com)
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
If you prefer www as canonical, flip the target instead:
RewriteEngine On
# Force HTTPS and force www (www.example.com)
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Nginx rules
On Nginx you use dedicated server blocks rather than rewrite hacks, which is faster and easier to read. The cleanest pattern is a small redirect server that catches every insecure or wrong-host request and 301s it to your canonical, plus your real HTTPS server. This example forces HTTPS and non-www.
# Redirect all http and www traffic to the secure canonical
server {
listen 80;
listen 443 ssl;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
# The real, canonical secure server
server {
listen 443 ssl;
server_name example.com;
# ssl_certificate and site config go here
}
Notice that both examples use a permanent 301 and preserve the full request path, so a visitor landing on http://www.example.com/blog/post is sent to https://example.com/blog/post rather than dumped on the homepage. Preserving the path is essential, otherwise every deep link and every indexed URL redirects to the root and you lose the ranking value of those pages.
Best practices and common mistakes
The redirect rule itself is short, but small errors around it cause most of the pain. Follow these practices to keep your force https redirect clean, fast, and safe.
- Avoid redirect chains. Sending http://www to https://www to https://non-www is two hops when it should be one. Chains slow the page, waste crawl budget, and can dilute signals. Configure the rule so any variant reaches the final canonical in a single 301.
- Update your internal links. After you set the canonical, change your menus, buttons, sitemap, and canonical tags to point directly at the final URL. Relying on the redirect to fix internal links means every click pays a redirect penalty that you could have avoided.
- Test before you deploy to production. Try the rules on a staging copy first. A wrong regex can create a redirect loop that takes your whole site offline. Confirm behavior on staging, then push to live.
- Use 301, never 302, for canonicalization. A temporary redirect will not pass full ranking value and can keep the wrong URL indexed. Double check the status code with a header checker after deploying.
- Fix mixed content after forcing HTTPS. Once the site is secure, hunt down any images, scripts, or stylesheets still loaded over http://. Mixed content triggers browser warnings and can block resources from loading.
- Update Google Search Console and your sitemap. Make sure your Search Console property and your XML sitemap reference the canonical secure version so Google recrawls the right URLs quickly.
When to use a force https redirect
You should set up a force https redirect any time your site can be reached at more than one address or over an insecure connection. A few specific moments make it urgent, because that is when duplicate or insecure URLs get created and start leaking signals.
- Right after installing an SSL certificate. Adding SSL makes the https:// version available, but it does not remove the http:// version. Until you force the redirect, both exist in parallel and browsers may still serve the insecure one. The redirect is what actually completes the move to HTTPS.
- During a site migration or redesign. New platforms, new hosts, and new URL structures are prime moments for canonical drift. Locking in one secure www or non-www canonical during the migration prevents the old and new versions from competing.
- When you spot duplicate indexing. If Search Console or a site search shows both www and non-www, or both http and https versions of your pages, a force https redirect is the direct fix. It tells Google which single version to keep.
- At every new site launch. Set the canonical redirect before you build links or publish content, so authority accumulates on the right URL from day one instead of being reorganized later.
Frequently asked questions
Does forcing HTTPS actually help my Google rankings?
Yes, in two ways. HTTPS is a confirmed, lightweight ranking signal, so the secure version has a small direct edge. More importantly, a clean force https redirect removes duplicate URLs and consolidates your backlinks onto one page, which is the larger practical gain. It also stops browsers from showing "Not Secure" warnings that scare visitors away.
Should I choose www or non-www as my canonical?
Either works, because Google treats them equally. Pick based on preference and setup. Non-www is shorter and popular with modern brands. The www prefix gives you more DNS and CDN flexibility since it can use a CNAME. The only real rule is to choose one, enforce it everywhere, and never keep both live.
What is the difference between a 301 and a 302 redirect here?
A 301 is permanent and passes ranking signals to the destination while updating the search index. A 302 is temporary and keeps the original URL indexed. For canonicalization and HTTPS enforcement you always want a 301. Using a 302 by accident can prevent link equity from transferring and leave the wrong version ranking.
Will a force https redirect slow down my website?
A single redirect adds one small, one-time hop, which is negligible. Problems only appear with redirect chains, where a request bounces through several URLs before landing. Configure your rules so any variant reaches the final canonical in exactly one 301, and update internal links to point directly at it, and the speed cost is effectively zero.
Do I still need canonical tags if I have the redirect?
Redirects and canonical tags solve different layers. The server redirect handles the http, https, www, and non-www variants at the domain level. Canonical tags handle duplicate content within your chosen domain, such as URL parameters and print versions. Use both together for full coverage rather than treating one as a replacement for the other.
What if I use both Apache and Nginx, or a CDN?
Apply the redirect at the layer closest to the visitor. If a CDN like Cloudflare sits in front, you can enforce HTTPS and the canonical host there, then keep a matching rule on your origin server as a safety net. Just avoid stacking conflicting rules, which is a common cause of redirect loops.
Ready to lock in your canonical domain?
Generating the rules is step one. Seeing whether your fix actually improved how you rank across the map is where ProMapRanker comes in. Once your force https redirect is live and your site is serving one clean, secure canonical, you can track your local search visibility and watch your consolidated authority pay off in the map pack. Start free with 150 credits and turn a tidy redirect setup into measurable ranking gains.
Related tools
- .htaccess Redirect Generator: build individual Apache redirect rules for single pages, folders, or full domain moves.
- Nginx Redirect Generator: create clean server-block redirects for Nginx without hand-writing regex.
- Redirect Type Helper: decide when to use a 301, 302, or other redirect type for any situation.
- Canonical Tag Generator: produce the rel=canonical tags that handle duplicate content within your chosen domain.
- Robots.txt Generator: control how crawlers access your newly consolidated, secure site.
Related tools
301 vs 302 Redirect Decision Helper
Answer a few questions and get the correct redirect type and exact rule to use, avoiding the SEO damage of the wrong choice.
Open →Canonical Tag Generator
Produce a correct rel=canonical tag to consolidate duplicate URLs and protect ranking signals. Simple but commonly misconfigured.
Open →Crawl Budget Estimator
Estimate how long Google needs to crawl your site from its size and crawl rate, so you can prioritize technical fixes.
Open →Hreflang Tag Generator
Generate correct hreflang link tags for multilingual and multi-region sites, including x-default. Prevents the most common international SEO mistakes.
Open →htaccess Redirect Generator
Generate correct 301/302 redirect rules and common rewrite snippets for your .htaccess file. Saves agencies time and errors during migrations.
Open →Nginx Redirect Generator
Generate clean Nginx redirect rules for single URLs, folders or full domain moves without hand-writing server config.
Open →Track your real Google Maps rankings
These free tools get you set up - ProMapRanker shows where you actually rank across your whole service area on a geo-grid.
Start free - 150 credits