Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

If request on port 80, auto redirect to 443 equivalent - Moodle Course Management System

2.1 Installation of Moodle on a supported virtualmin server running Ubuntu Server 10.04 LTS

I have config file to say that the URI root should be https://mobilek16.net

When users put http://mobilek16.net, they get the error I have shown in screenshot.

I want to auto redirect them if the come in on port 80 but I can't get it to work.

I tried adding at top of index.php something like

<?php
if ($_SERVER['SERVER_PORT']<>443) {
header('Location: https://mobilek16.net');      
}
      ?>

But it is not working either.

Any assistance will be greatly appreciated ;-)
0
smetterd
Asked:
smetterd
  • 2
1 Solution
 
smetterdAuthor Commented:
SSL Error message from Moodle LMS
0
 
hieloCommented:
try:
<?php
if ( intval($_SERVER['SERVER_PORT']) != 443) {
  header('Location: https://mobilek16.net');
  exit;
}
?>

If that does not work, try:
<?php
if ($_SERVER['HTTPS']=='' || strtolower($_SERVER['HTTPS'])=='off' ) {
  header('Location: https://mobilek16.net');
  exit;
}
?>

Open in new window

0
 
smetterdAuthor Commented:
Gorgeous... didn't try the second suggestion b/c the first one works!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now