Add Forfully Redirect http to https using php code without .htaccess
This tutorial is for redirecting the http URL to https using the PHP code if your .htaccess will not work for the SSL. It will just redirect all your HTTP URLs to HTTPS without using the .htaccess if your server HTTPS is not on. Just follow the step, and you can get your own redirection.
Step 1)
Just put this code in your main root file or connection file, which is included everywhere inyour project. So every time a URL is scanned with this code, if it finds the http, it will convert it into https.
if (!(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' ||
$_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
{
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
Saved as a favorite, I really like your web site!
I am sure this piece of writing has touched all the internet viewers, its really really nice article on building up new weblog.
Ahaa, its nice discussion regarding this piece of writing at this place at this blog, I have read all that, so at this time me also commenting at this place.
Hola! I’ve been reading your blog for some time now and finally got the bravery to go ahead and give you a shout out from Dallas Tx! Just wanted to tell you keep up the excellent work!
What’s up, I check your blogs regularly. Your humoristic style is witty, keep up the good work!
I visited multiple blogs but the audio quality for audio songs present at this web site is actually excellent.
Hello! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing months of hard work due to no back up. Do you have any methods to protect against hackers?
These are truly great ideas in concerning blogging. You have touched some fastidious factors here. Any way keep up wrinting.
Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! However, how can we communicate?
You made some decent points there. I looked on the internet for more info about the issue and found most individuals will go along with your views on this website.
I just couldn’t depart your website before suggesting that I really loved the usual info an individual provide in your guests? Is going to be again ceaselessly in order to check out new posts
Ahaa, its fastidious discussion concerning this piece of writing here at this web site, I have read all that, so now me also commenting at this place.
There’s certainly a lot to know about this issue. I really like all of the points you made.
Ahaa, its good discussion about this article here at this web site, I have read all that, so now me also commenting at this place.
There is certainly a lot to know about this issue. I like all the points you have made.
It’s awesome in support of me to have a web page, which is valuable designed for my know-how. thanks admin
I’ll immediately clutch your rss as I can’t in finding your email subscription link or newsletter service. Do you have any? Kindly allow me know in order that I may subscribe. Thanks.
I am surfe thi paragrawph hhas touched alll thee internet viewers, itss rsally realy nnice piece of wrioting oon buildung uup new weblog.
Wow! This blog looks exactly like my old one! It’s on a totally different topic but it has pretty much the same page layout and design. Wonderful choice of colors!
There’s certainly a great deal to know about this issue. I really like all of the points you have made.
You should take part in a contest for one of the finest blogs online. I will highly recommend this web site!
I am sure this article has touched all the internet people, its really really pleasant post on building up new website.
I am sure this article has touched all the internet visitors, its really really pleasant paragraph on building up new blog.
Ahaa, its nice discussion concerning this piece of writing at this place at this web site, I have read all that, so now me also commenting at this place.
I will immediately snatch your rss feed as I can not in finding your email subscription hyperlink or newsletter service. Do you have any? Please permit me recognise in order that I may just subscribe. Thanks.
I every time spent my half an hour to read this blog’s articles daily along with a mug of coffee.