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

  • Home
  • SEARCH
  • 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 8023247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:30:42+00:00 2026-06-04T22:30:42+00:00

I am using .htaccess to redirect all requests (except to subdomains) from HTTP to

  • 0

I am using .htaccess to redirect all requests (except to subdomains) from HTTP to HTTPS. This code works for me just fine:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !=m.example.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

However, it does not prevent the user from manually attempting to access the subdomain using the HTTPS (The SSL that I have does not cover subdomains and shows trust error when used for sub-domains).

Now, I am wondering:

1-How can I redirect all HTTPS requests to subdomain back to HTTP?

2-How can I modify this code to dynamically apply the subdomain restrictions to other subdomains (not only m.example.com)

  • 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-06-04T22:30:44+00:00Added an answer on June 4, 2026 at 10:30 pm

    1) If the certificate doesn’t include m.example.com, you can never send the redirect, since the browser will refuse to make a connection. So there is no way of doing this.

    2) So all you want the htaccess to do is redirect the naked domain to https. To do this use:

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
    

    I case the certificate also includes www.example.com use

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using .htaccess, I need to redirect all requests from http://www.domain, http://domain, https://domain to; https://www.domain.com
I've got htaccess set up that redirects all subdomains except www to https. However
hello i'm using this .htaccess code to redirect urls. RewriteEngine on RewriteRule ^printer/([^/\.]+)/?$ printer.php?id=$1
I just tried to add the following htaccess rules to redirect all https urls
I'm using CodeIgniter and I added some rules in .htaccess to redirect all requests
At the moment I'm using Apache's mod_rewrite to redirect all html requests to http(s)://www.domain.com/blah
I would like to redirect all images to a showimage.php, using htaccess But if
I'm using this format in my htaccess to redirect several pages/links: RewriteEngine On RewriteRule
I am using this rule into my .htaccess to redirect IE 6 and 7
I'm trying to implement a solution using .htaccess and wildcard subdomains so that http://subdomain.example.com

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.