1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

i want to redirect http and www request to https

Discussion in 'Apache' started by donsr, Dec 18, 2013.

  1. #1
    i want to redirect main domain http //, www request to https://

    i added this code

    RewriteCond %{HTTPS} off
    # First rewrite to HTTPS:
    # Don't put www. here. If it is already there it will be included, if not
    # the subsequent rule will catch it.
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Now, rewrite any request to the wrong domain to use www.
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    Code (markup):
    but it affect to my subdomains also i dont want to affect my subdomains ..how to redirect only main domain?
     
    donsr, Dec 18, 2013 IP
  2. crivion

    crivion Well-Known Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    160
    Digital Goods:
    3
    #2
    RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com [NC]
     
    crivion, Dec 19, 2013 IP
  3. donsr

    donsr Well-Known Member

    Messages:
    219
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    160
    #3
    thanks
     
    donsr, Dec 20, 2013 IP