Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 811587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:04:07+00:00 2026-05-15T01:04:07+00:00

I have a dilemma with this one. With the following code I am able

  • 0

I have a dilemma with this one. With the following code I am able to force SSL on any non SSL url, however when the user (and results from Google) take the user to http://mysite.co.za then we hit an issue as the url is then rewritten to https://mysite.co.za

Due to the fact that my certificate is bound to http://www.mysite.co.za it immediately throws a security error because of the missing ‘www’ in the url.

Can someone point out a way to add the www to the domain when the domain starts with HTTPS and not HTTP?

Much appreciated.

And the current code to add the https:// is as follows:

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:04:07+00:00Added an answer on May 15, 2026 at 1:04 am

    Can someone point out a way to add the www to the domain when the domain starts with HTTPS and not HTTP?

    So you want this:

    • If the host does not start with www:
      • If the connection is secure, do nothing. In this case you’re already screwed anyway, because the user has already seen the host mismatch warning.
      • If the connect is not secure redirect to https://www.%{HTTP_HOST}%{REQUEST_URI}

    Your current rule:

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    This rule fails on you because it adds www no matter whether the connection is secure or not. Additionally, it keeps plain http the way it is (no forward to https://).

    The rule that satisfy your requirements above is

    #if the host does not start with www.
    RewriteCond %{HTTP_HOST} !^www\.
    #and the connection is not secure
    RewriteCond %{HTTPS} =""
    #forward
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301]
    

    The L flag is unnecessary because a redirect ends the rewriting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, my dilemma is this. I have an admin page that I use to
One of the most common dilemmas I have when commenting code is how to
Have you guys had any experiences (positive or negative) by placing your source code/solution
I have a little dilemma that maybe you can help me sort out. I've
I have a little dilemma on how to set up my visual studio builds
Ok, here is my dilemma I have a database set up with about 5
Where I work we have a little bit of a dilemma... I work on
I've hit a small dilemma! I have a handler called vote; when it is
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Hopefully this will be clear enough. I have a 2d map made of tiles,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.