.htaccess redirect with SSL without www

Posted on 2008-11-09
Last Modified: 2013-11-19
I am having difficulty writing a .htaccess redirect code that does the following two things:

1. redirects http to https
2. redirect to

Here are a few scenarios I am trying to fullfill

a.  -->
b.    --->
c.   -->

Question by:dmehran
    LVL 12

    Expert Comment

    This should work for you

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$$1 [R,L]

    The above redirects from http to https

    Try that on its own first if it does not completely work try adding the following  

    RewriteCond %{HTTP_HOST} ^                      
    RewriteRule (.*)$1 [R=301,L]

    The above redirects to



    Author Comment


    Thanks for the solution. Your recipe  improved the situation quite a bit. However, the only situation that doesn't redirect properly is the URL:   (it doesn't redirect at all)

    The following scenarios now get redirected successfully:  -->    -->   -->

    Any ideas?
    LVL 12

    Accepted Solution

    Ok then .net was not inlcuded in your original question.

    Where do you want that to redirect to? htttp:// Add these 3 lines too!

    RewriteCond %{HTTP_HOST} ^
    RewriteCond %{SERVER_PORT} 443
    RewriteRule (.*)$1 [R=301,L]

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web developeā€¦
    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now