How to re-write all https:// traffic to http:// via .htaccess

Discussion in 'Apache' started by SpotOn SEO Services, Aug 19, 2009.

  1. #1
    I have a site with a shopping cart which has been changed to a lead generation site. There is no longer a need for https:// pages. Any ideas on how I can use .htaccess to 301 all https:// to its equivalent http:// page?

    Thanks in advance!
     
    SpotOn SEO Services, Aug 19, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine On
    
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    Code (markup):
     
    premiumscripts, Aug 19, 2009 IP
  3. SpotOn SEO Services

    SpotOn SEO Services Greenhorn

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #3
    Did I need to customize this at all? It does not seem to work just inserting as you recommended.

    Here is my .htaccess code:

    #DirectoryIndex home.html index.html index.php
    
    # Ultimate SEO URLs BEGIN
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^home.html$ /index.html [L]
    
    RewriteCond %{QUERY_STRING} ^options\=(.*)$
    RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2%1
    RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-a-(.*).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pr-(.*).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pri-(.*).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pm-([0-9]+).html$ info_pages.php?pages_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-i-(.*).html$ information.php?info_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
    # Added polls and newsdesk
    #RewriteRule ^(.*)-po-([0-9]+).html$ pollbooth.php?pollid=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-n-(.*).html$ newsdesk_info.php?newsdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-nc-(.*).html$ newsdesk_index.php?newsPath=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-nri-(.*).html$ newsdesk_reviews_info.php?newsdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-nra-(.*).html$ newsdesk_reviews_article.php?newsdesk_id=$2&%{QUERY_STRING}
    # BOF: Faqdesk support added by faaliyet
      RewriteRule ^(.*)-f-(.*).html$ faqdesk_info.php?faqdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-fc-(.*).html$ faqdesk_index.php?faqPath=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-fri-(.*).html$ faqdesk_reviews_info.php?faqdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-fra-(.*).html$ faqdesk_reviews_article.php?faqdesk_id=$2&%{QUERY_STRING}
    # EOF: Faqdesk support added by faaliyet
    # Ultimate SEO URLs END
    
    RewriteCond %{HTTP_HOST} ^mysite.com [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
    
    # redirect https to http domain  
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    Code (markup):
     
    SpotOn SEO Services, Aug 19, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try placing it below rewriteengine on. It should work (it does for me)
     
    premiumscripts, Aug 19, 2009 IP
  5. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can also try this rewritecondition if it still doesn't work:

    RewriteCond %{SERVER_PORT} 443

    And if you have your SSL site in a different directory, you'll have to create the .htaccess there.
     
    premiumscripts, Aug 19, 2009 IP
  6. SpotOn SEO Services

    SpotOn SEO Services Greenhorn

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #6
    Tried this and it still does not work. Could it be an issue with this:

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

    This appears further down in .htaccess

    #DirectoryIndex home.html index.html index.php
    
    # Ultimate SEO URLs BEGIN
    Options +FollowSymLinks
    RewriteEngine On
    # redirect https to http domain  
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteBase /
    
    RewriteRule ^home.html$ /index.html [L]
    
    RewriteCond %{QUERY_STRING} ^options\=(.*)$
    RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2%1
    RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-a-(.*).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pr-(.*).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pri-(.*).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-pm-([0-9]+).html$ info_pages.php?pages_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-i-(.*).html$ information.php?info_id=$2&%{QUERY_STRING}
    RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
    # Added polls and newsdesk
    #RewriteRule ^(.*)-po-([0-9]+).html$ pollbooth.php?pollid=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-n-(.*).html$ newsdesk_info.php?newsdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-nc-(.*).html$ newsdesk_index.php?newsPath=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-nri-(.*).html$ newsdesk_reviews_info.php?newsdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-nra-(.*).html$ newsdesk_reviews_article.php?newsdesk_id=$2&%{QUERY_STRING}
    # BOF: Faqdesk support added by faaliyet
      RewriteRule ^(.*)-f-(.*).html$ faqdesk_info.php?faqdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-fc-(.*).html$ faqdesk_index.php?faqPath=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-fri-(.*).html$ faqdesk_reviews_info.php?faqdesk_id=$2&%{QUERY_STRING}
      RewriteRule ^(.*)-fra-(.*).html$ faqdesk_reviews_article.php?faqdesk_id=$2&%{QUERY_STRING}
    # EOF: Faqdesk support added by faaliyet
    # Ultimate SEO URLs END
    Code (markup):
     
    SpotOn SEO Services, Aug 19, 2009 IP
  7. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm sorry mate, can't help you any further. This works on my system. You could try and remove the rest of the htaccess momentarily to test that theory though. However, normally only 1 rewriterule is executed (it can't redirect twice) so it's unlikely..
     
    premiumscripts, Aug 19, 2009 IP
  8. SpotOn SEO Services

    SpotOn SEO Services Greenhorn

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #8
    If nothing else it would be helpful to have all https:// to be re-directed to the 404 page.
     
    SpotOn SEO Services, Aug 19, 2009 IP
  9. SpotOn SEO Services

    SpotOn SEO Services Greenhorn

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #9
    Any other .htaccess gurus have ideas on this?
     
    SpotOn SEO Services, Aug 20, 2009 IP
  10. vindointernational

    vindointernational Greenhorn

    Messages:
    58
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #10
    do you have VPS or access to apache config ?
     
    vindointernational, Aug 21, 2009 IP
  11. SpotOn SEO Services

    SpotOn SEO Services Greenhorn

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #11
    Not sure this on a HostGator server.
     
    SpotOn SEO Services, Aug 21, 2009 IP