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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:30:18+00:00 2026-05-24T05:30:18+00:00

I would like to force the browser to redirect to HTTPS always if someone

  • 0

I would like to force the browser to redirect to HTTPS always if someone types in:

http://www.mydomain.com/user
or
http://www.mydomain.com/user/

Both of the above 2 links should redirect to: https://www.mydomain.com/user

Right now the 2nd to bottom line of code works correctly:

RewriteRule ^user$ https://www.mydomain.com/user/ [R,QSA]

will indeed redirect the browser to HTTPS but if http://www.mydomain.com/user/ is input then it won’t redirect to HTTPS. How can I achieve this?

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

RewriteRule ^user$ https://www.mydomain.com/user/ [R,QSA]
RewriteRule ^user/$ public/index.php?var1=x&var2=y [L,QSA]
  • 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-24T05:30:20+00:00Added an answer on May 24, 2026 at 5:30 am

    Use these rules:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    
    # force www domain name
    RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
    RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
    
    # force HTTPS for some pages
    RewriteCond %{HTTPS} =off [NC]
    RewriteRule ^user/?$ https://www.mydomain.com/user/ [R=301,L]
    
    RewriteRule ^user/$ public/index.php?var1=x&var2=y [L,QSA]
    

    It will redirect to HTTPS:

    • if HTTP is current protocol (so no redirection if already on HTTPS)
    • regardless of trailing slash presence: both /user and /user/ will do the job (but will do nothing if /user/something-here will be requested).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to force svcutil to generate all data contracts in an assembly
We would like to force encryption of the data going to and from our
I would like to force a \marginpar to appear on the wrong side of
I have an application I would like to force SSL on the login page
If I have an object that I would like to force to be accessed
I would like to run multiple copies of my application and force the first
I would like to know whether it is possible to force LWP::UserAgent to accept
I have a string property that I would like to be able to force
I would like the browser to keep the page open until the ajax requests
I would like to provide my Python GAE website in the user's own language,

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.