https mod rewrite questions

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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
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

if (!isset($_SERVER["HTTPS"]))
    $secure_url = 'https://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    header("Location: $secure_url");


Open in new window

HTH, ~Ray
Dave BaldwinFixer of ProblemsCommented:
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 ^(.*)$$1 [R,L]

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LueyAuthor Commented:
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 ^(.*)$$1 [R=301,L]

Open in new window

Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Dave BaldwinFixer of ProblemsCommented:
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$1 .  If it has only your domain, then you must use$1 .
LueyAuthor Commented:
I will look at the certificate info.  Thanks a bunch
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.