Help with Setting Certain Links to HTTP and HTTPS
I have an newly installed SSL certificate on my website and
I am trying to figure out how to make some pages point specifically to https and other point only to http.For example, if someone is on my website browsing my webpages via https,
and I only need my testimonials and about us page to be http, is this possible?I know this is possible with hard coding all of the links on the site but I am and already have setup relative links.
Is there a way to maybe add a setting in the .htaccess file that will开发者_如何学Go point the server to http when someone tried to visit my testimonials and about us page?
Write below code in your .htaccess file
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} Page-1 [OR]
RewriteCond %{REQUEST_URI} page-2
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If you are using php then you can put the following codes in your files.
To Redirect from HTTP to HTTPS:
if(empty($_SERVER['HTTPS']))
{
header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
}
To Redirect from HTTPS to HTTP:
if(!empty($_SERVER['HTTPS']))
{
header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
}
精彩评论