Solved

https  mod rewrite questions

Posted on 2013-12-28
6
330 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
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 83

Accepted Solution

by:
Dave Baldwin earned 500 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 83

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 83

Expert Comment

by:Dave Baldwin
ID: 39744221
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.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

13 Experts available now in Live!

Get 1:1 Help Now