sr98bj Posted January 5, 2011 Share Posted January 5, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/223430-ssl-and-php-how-to-turn-onoff-ssl-for-entire-website/ Share on other sites More sharing options...
BlueSkyIS Posted January 5, 2011 Share Posted January 5, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/223430-ssl-and-php-how-to-turn-onoff-ssl-for-entire-website/#findComment-1155000 Share on other sites More sharing options...
sr98bj Posted January 5, 2011 Author Share Posted January 5, 2011 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]?? Quote Link to comment https://forums.phpfreaks.com/topic/223430-ssl-and-php-how-to-turn-onoff-ssl-for-entire-website/#findComment-1155023 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.