Data at Your Fingertips: Explore Our New Reporting and Statistical Capabilities By Ryan Ashbrook 23 hours ago
SPICE Posted February 9, 2015 Share Posted February 9, 2015 Hello everyone,I am currently removing the SSL certificate from my board and I got stuck at redirecting all the HTTPS url's to HTTP. Now, I have the code, which I had in initdata.php for redirecting all HTTP traffic to HTTPS, but now I need to do the opposite. Here is the code:if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') { if(!headers_sent()) { header("Status: 301 Moved Permanently"); header(sprintf( 'Location: https://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] )); exit(); } }Can I do the reverse, and if so, how?It would be really helpful if there is a way to do this with .htaccess too. I tried several Rewrite rules, but every one of them gave me wrong redirection and if you click a link from Google, you go to the homepage. Link to comment Share on other sites More sharing options...
sijad Posted February 9, 2015 Share Posted February 9, 2015 i would use .httaccess but this code should worksif ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || $_SERVER['SERVER_PORT'] == 443) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit(); } as you want to force users to use http, there's no need to any conditions, I've changed the code Link to comment Share on other sites More sharing options...
SPICE Posted February 9, 2015 Author Share Posted February 9, 2015 Thank you very much! It worked flawlessly. Link to comment Share on other sites More sharing options...
SPICE Posted February 10, 2015 Author Share Posted February 10, 2015 Actually, now when I tested it out more in depth, it seems that brakes somehow the "Online Members" section, and there is only me there. Or max 1 or 2 people, which is really weird, because I am sure that there's more than 2 people online. Link to comment Share on other sites More sharing options...
sijad Posted February 10, 2015 Share Posted February 10, 2015 did you tried .httaccess?this code should worksOptions +FollowSymLinks RewriteEngine On RewriteCond %{ENV:HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]orRewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}i don't have apache server so i couldn't test it my self, I've copied it from here: http://stackoverflow.com/questions/8371/how-do-you-redirect-https-to-http Link to comment Share on other sites More sharing options...
SPICE Posted February 10, 2015 Author Share Posted February 10, 2015 I've tried most of these codes from stackoverflow. The problem is that if there is any https link from Google to a topic, when you click it, you get redirected to the homepage with /index.php in the url. If I get the RewriteRule url correct, I think it should be fine. Link to comment Share on other sites More sharing options...
sijad Posted February 10, 2015 Share Posted February 10, 2015 that code should works, i guess there's another code in htaccess that conflicts with this one Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.