Solved

https  mod rewrite questions

Posted on 2013-12-28
6
328 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
  • 3
  • 2
6 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
I will look at the certificate info.  Thanks a bunch
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You're welcome, glad to help.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Imagine a situation that you have installed SSL (http://en.wikipedia.org/wiki/Secure_Sockets_Layer) Certificate on your Cisco ASA (Cisco Adaptive Security Appliance) firewall. Installation of SSL certificate on ASA is an another topic for which you …
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 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

6 Experts available now in Live!

Get 1:1 Help Now