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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:27:15+00:00 2026-05-26T17:27:15+00:00

Here’s what I am trying to do. I have a few scripts on a

  • 0

Here’s what I am trying to do. I have a few scripts on a site I am rewriting the URLs to force them to use https://. What I then want to do, is rewrite urls when I navigate away from the HTTPS pages back to HTTP. Here’s what I have now that is not working exactly the way I would like it to.

# For HTTPS pages:
RewriteCond %{HTTPS} off
RewriteRule ^(register/|cms/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]

# For non-HTTPS pages:
RewriteCond %{HTTPS} on
RewriteRule ^(about/|contact/)$ http://%{HTTP_HOST}/$1 [R=301,L]

The problem I am having is that while the pages like about/ and contact/ rewrite back to HTTP, I can’t figure out how to reference the document root, so it unfortunately stays https://. I like using relative urls, so I would rather not go into my source and change everything to absolute if there is a simple htaccess solution.

My question: How do I properly reference the web root in my RewriteRule?

Also, is there a more efficient, catch-all way of doing what I am trying to accomplish that I just don’t know about, because I haven’t been able to find anyone else with this problem. I am not super-familiar with .htaccess. I learn just enough as I go to do various Rewrite operations, as I will never have a need for the full features, and I find the documentation cumbersome and difficult to follow.

Thanks!

  • 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-26T17:27:15+00:00Added an answer on May 26, 2026 at 5:27 pm

    for matching the root use

    RewriteCond %{HTTPS} on
    RewriteRule ^$ http://%{HTTP_HOST}/$1 [R=301,L]
    

    or combine them with the other rule

    RewriteRule ^(about/|contact/|)$ http://%{HTTP_HOST}/$1 [R=301,L]
    

    As to the catch all expect /register and /cms (that’s what you mean right?). I think this should do the trick.

    # For HTTPS pages:
    RewriteCond %{HTTPS} off
    RewriteRule ^(register/|cms/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]
    
    #prevent rules beneath this one in this htaccess file from being applied when url start with register of cms (doesn't do anything else)
    RewriteRule ^(register/|cms/) - [L]
    
    #don't force http for resources, to prevent partial encryption errors
    RewriteRule ^(css/|images/) - [L]
    
    # For non-HTTPS pages:
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is what I want to do. Use this HTML line and have the
here is the site : http://www.notrepanorama.com at the bottom left, i use a jquery
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here is what I am trying to achieve in PHP: I have this string:
Here's the situation, i want to have a user that can enter time on
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here we go again, the old argument still arises... Would we better have a
Here's the basic setup: I have a thin bar at the top of a

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.