GeneralHTTPS (SSL) Only for logged in Users, Register and Login Pages in...

HTTPS (SSL) Only for logged in Users, Register and Login Pages in Question2Answer

Question2Answer is an open-source PHP forum script that can be download for free from question2answer.org. In this article we will guide you on, How you can enable or set HTTPS i.e. SSL only for signed users and sensitive pages like register, login and forget password.

In order to force the users to use HTTPS protocol instead of HTTP protocol in the cases like the user has logined, registering i.e signing up to your forum and resetting password you need to follow following steps:

  1. Locate the qa-theme folder in the default directory where you have installed the q2a forum
  2. Open your default theme’s folder
  3. Create a new PHP file and name it to ssl_secure.php
  4. Edit it once you have created ssl_secure.php file
  5. Now, add following PHP code into the file, ssl_secure.php and save it
<?php
if(!(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'))
{
$cur_uri=substr($_SERVER["REQUEST_URI"],0,20);
if( strpos($cur_uri, 'login') || strpos($cur_uri, 'register') || strpos($cur_uri, 'forgot')){
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
$userid=qa_get_logged_in_userid();
if(!empty($userid)) {
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
}
  1. Now located the qa-theme.php file and add following code at the top of the page just below the line <?php

include "ssl_secure.php";
That’s all you need to do.

Team Isrg KB
Team Isrg KB
Isrg Team editorial account handled by Isrg Team, management, guests, volunteers, and other private individual contributors

Latest Updates

OTT Platform, Horror Movie, Watching Tv, Movie, Remote

Censorship of Web series and its Pros and Cons

Censorship of Web series and its Pros and Cons has both a negative and positive impact on people and individuals in society 
European Union, Russia, Oil Supply, Gas, Supply

The EU oil price cap may result in ‘violent’ surges, according to the Economist

The EU oil price cap may result in 'violent' surges, according to the Economist. As the European Union’s sanctions on Russian oil are about to kick in ...
Tiktok Megha Thakur

Megha Thakur, a TikTok celebrity, died ‘unexpectedly’ at the age of 21

Megha Thakur, a TikTok celebrity, died 'unexpectedly' at the age of 21. Canadian influencer Megha Thakur has died “suddenly and unexpectedly” at the age ...