Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

https  mod rewrite questions

Posted on 2013-12-28
6
Medium Priority
?
340 Views
Last Modified: 2013-12-28
Hello I have a site that I need to run the entire site on https protocol.   I am not sure what I need to do in my htaccess file to make that happen.  I already have my SSL.


RewriteCond %{HTTP_HOST} ^prizemagnet\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.prizemagnet\.com$

RewriteRule ^index\.php$ "http\:\/\/www\.prizemagnet\.com\/" [R=301,L,QSA,NC]

Open in new window

0
Comment
Question by:Luey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39744044
Step one: Contact your hosting company and tell them what you want to do.

You can use PHP to make an HTTPS-only script with something like this.
<?php // RAY_https.php
error_reporting(E_ALL);
 
// ONLY RUN THIS SCRIPT UNDER HTTPS

// WE ARE NOT UNDER HTTPS
if (!isset($_SERVER["HTTPS"]))
{
    $secure_url = 'https://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    header("Location: $secure_url");
    exit;
}

// THE REST OF THE SCRIPT IS HERE.
phpinfo();

Open in new window

HTH, ~Ray
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 39744049
Your code appears to only redirect for 'index.php'.  This code is supposed to redirect all requests to 'HTTPS'.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R,L]

Open in new window

0
 

Author Comment

by:Luey
ID: 39744162
I have contacted my hosting company and they gave me a code exactly like Dave's.  I have one more question on this please.  Do I need to 2 rewrite conditions I previously had and how should I be redirecting my index.php.


This is the code they said use just like Dave.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

Open in new window

0
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39744169
That statement redirects ALL requests from HTTP to HTTPS.  You don't need a special case for 'index.php'.  You do want to make sure that the domain you use after 'https' is exactly the domain in your certificate.  If your cert has 'www', then you must use https://www.example.com/$1 .  If it has only your domain, then you must use https://example.com/$1 .
0
 

Author Closing Comment

by:Luey
ID: 39744172
I will look at the certificate info.  Thanks a bunch
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39744221
You're welcome, glad to help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

609 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