Solved

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

Posted on 2011-09-14
3
522 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
  • 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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checking CSRF token within a function 36 75
paypal ipn url 5 58
Google Maps API and PHP 25 32
How would I do this...? 2 28
This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 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