Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-14
3
Medium Priority
?
548 Views
Last Modified: 2012-05-12
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
Comment
Question by:smetterd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Author Comment

by:smetterd
ID: 36535861
SSL Error message from Moodle LMS
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 36535956
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
 
LVL 2

Author Comment

by:smetterd
ID: 36535991
Gorgeous... didn't try the second suggestion b/c the first one works!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question