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 7085289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:24:23+00:00 2026-05-28T07:24:23+00:00

Could anybody please help me to write rewriterule, that redirects http<->https (back and force

  • 0

Could anybody please help me to write rewriterule, that redirects http<->https (back and force depending of URL typed) with these conditions:

1) http://www.mydomain.com , http://www.mydomain.com/?p=home , http://www.mydomain.com/?p=home1 , http://www.mydomain.com/?qqq=home are always http, even if https are typed instead of http.

2) all the rest pages are always https, even if http was typed instead of https.

The code below redirects all urls (and keeps parameters), except http://www.mydomain.com , to https.

#redirects http to https if there are parameters
RewriteCond %{HTTPS} off
RewriteCond %{QUERY_STRING} !^$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I’ve tried to add the code below right after the code above to redirect https to http as well (if there are no parametres), so that all pages are always https, except http://www.mydomain.com, but I had no luck. Also I missed ?p=home, ?p=home1, ?qqq=home – I don’t know how to add them.

RewriteCond %{HTTP} off
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
  • 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-28T07:24:24+00:00Added an answer on May 28, 2026 at 7:24 am

    Try adding the following to your htaccess file in the root directory of your site.

    RewriteEngine on
    RewriteBase /
    
    #determine if page is supposed to be http
    #if it has p=home or p=home1 or qqq=home in querystring
    RewriteCond %{QUERY_STRING} (^|&)(p=home1?|qqq=home)(&|$) [NC,OR]
    #or if query string is empty
    RewriteCond %{QUERY_STRING} ^$
    #set env var to 1
    RewriteRule ^ - [E=IS_HTTP:1]
    
    
    #all pages that are supposed to be http redirected if https
    RewriteCond %{HTTPS} on
    RewriteCond %{ENV:IS_HTTP} 1
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
    
    #all other pages are sent to https if not already so
    RewriteCond %{HTTPS} off
    RewriteCond %{ENV:IS_HTTP} !1
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

could please anybody help me to install spring surf ? According to this video
Could please anybody help me to sort it out? It can be done like
Can anybody please explain how this could possibly happen? I am completely aware of
Does anybody know where I could find WinForms controls that mimic those on the
Could anybody please tell me which is best guide/book/material for socket programming in C?
Hey, I'm talking about profiles within pom.xml of a project. Could please anybody explain
Could anybody explain in plain words how Cloud computing works? I have read the
Could anybody explain what is the cause of the following: >>> from M2Crypto import
Could anybody be so kind to give me a simple example of reification in
Could anybody explain to me the process of uploading to and downloading form and

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.