Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
SPICE Posted February 9, 2015 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.
sijad Posted February 9, 2015 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
SPICE Posted February 9, 2015 Author Posted February 9, 2015 Thank you very much! It worked flawlessly.
SPICE Posted February 10, 2015 Author 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.
sijad Posted February 10, 2015 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
SPICE Posted February 10, 2015 Author 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.
sijad Posted February 10, 2015 Posted February 10, 2015 that code should works, i guess there's another code in htaccess that conflicts with this one
Recommended Posts
Archived
This topic is now archived and is closed to further replies.