?
Solved

https  mod rewrite questions

Posted on 2013-12-28
6
Medium Priority
?
339 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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

777 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