Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted February 9, 201510 yr 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.
February 9, 201510 yr 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
February 10, 201510 yr Author 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.
February 10, 201510 yr 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
February 10, 201510 yr Author 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.
February 10, 201510 yr that code should works, i guess there's another code in htaccess that conflicts with this one
Archived
This topic is now archived and is closed to further replies.