Jump to content

SSL and PHP how to turn on/off SSL for entire website


sr98bj

Recommended Posts

Hello,

 

Im new to PHP and trying to help out a customer that has an all PHP website that currently has HTTPS turned on for the entire site.  Looking at the .htaccess file on the server, I noticed the following code:

 

RewriteEngine On

#RewriteBase /~mysite

 

RewriteCond %{HTTP_HOST} ^mysite.com

RewriteRule (.*) https://www.mysite.com/$1 [R=301,L]

 

RewriteCond %{HTTPS} off

 

Does this code turn SSL on for the entire website? If so, can I change by removing:

 

RewriteRule (.*) https://www.mysite.com/$1 [R=301,L]

 

and I only want to turn HTTPS on for a few PHP scripts/pages, how would I do this?

Link to comment
Share on other sites

this is example of .htaccess to turn on ssl for specific pages and turn it off for other pages

 

RewriteEngine On

# Send everyone in these dirs and pages to https
RewriteCond %{HTTP_HOST} ^www\.somewebsite\.com$ [NC]
RewriteCond %{REQUEST_URI} clubs [OR,NC]
RewriteCond %{REQUEST_URI} dealer/ [OR,NC]
RewriteCond %{REQUEST_URI} login.html [OR,NC]
RewriteCond %{REQUEST_URI} dealer_registration.html [OR,NC]
RewriteCond %{REQUEST_URI} club_registration.html [OR,NC]
RewriteCond %{REQUEST_URI} contact.html [OR,NC]
RewriteCond %{REQUEST_URI} dealer_club_contact.html [OR,NC]
RewriteCond %{REQUEST_URI} members [OR,NC]
RewriteCond %{REQUEST_URI} secure/ [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L,QSA]

# Otherwise, make sure they aren't in https
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !dealer/ [NC]
RewriteCond %{REQUEST_URI} !login.html [NC]
RewriteCond %{REQUEST_URI} !dealer_registration.html [NC]
RewriteCond %{REQUEST_URI} !club_registration.html [NC]
RewriteCond %{REQUEST_URI} !contact.html [NC]
RewriteCond %{REQUEST_URI} !clubs [NC]
RewriteCond %{REQUEST_URI} !secure [NC]
RewriteCond %{REQUEST_URI} !securimage [NC]
RewriteCond %{REQUEST_URI} !members [NC]
RewriteCond %{REQUEST_URI} !images [NC]
RewriteCond %{REQUEST_URI} !css [NC]
RewriteCond %{REQUEST_URI} !jscripts [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L,QSA]

Link to comment
Share on other sites

Thank you, this helps me but Im still green at all of this.  This website has only a few pages that will be HTTPS, less than 5, the rest are all HTTP, so is there an easier way to make the entire website HTTP and only this 5 or fewer pages HTTPS? Also, what is the stuff in the brackets at the end [OR, NC]??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.