Redirect from secure https to http for only one page
11,390
Solution 1
This might also be a quick copy paste
if ($_SERVER['HTTPS'] == "on") {
$url = "http://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit;
}
Solution 2
if($_SERVER['SERVER_PORT'] == '443')
{
header('location:http://url.com');
}
if the secure port is set to other than 443 this will not work so you can also use
$_SERVER['HTTPS'] == 'on'
Author by
sotirios9
Updated on June 28, 2022Comments
-
sotirios9 almost 2 years
I have a page,
page.php
that I need to be redirected tohttp
if it is accessed throughhttps
because otherwise my google ads won't show up.To be precise, I would like the following to happen:
https://site.com/page.php?blah=foo?bar=blah
-->http://site.com/page.php?blah=foo?bar=blah
I have so far tried :
RewriteCond %{HTTP_HOST} on
RewriteRule ^page\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But this doesn't work. Any suggestions?