Double Slash at end of URL when going to HTTPS?

Posted by J M 4 on Stack Overflow See other posts from Stack Overflow or by J M 4
Published on 2010-05-11T21:27:57Z Indexed on 2010/05/11 21:34 UTC
Read the original article Hit count: 277

Filed under:
|
|
|

My site currently uses http and https sections based on the data being collected on the site (form data uses https).

On my index page, I have the PHP code at the top:

<?php
    session_start();
    ob_start();
    if( $_SERVER['SERVER_PORT'] == 443) {
        header('Location:http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])); 
        die();
    } 
?>

However, the page will not load and I get a 404 error. Similarly, when i visit the sections with https security using the head code:

<?php
session_start();
ob_start();
    if( $_SERVER['SERVER_PORT'] == 80) {
        header('Location:https://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'.basename($_SERVER['PHP_SELF'])); 
        die();
    }
?>

The site does not respond AND for some reason creates a double slash when switching from http to https.

Example: http://www.abc.com/, then clicking button which should route to enroll.php shows http://www.abc.com//enroll.php

why the need for the double slash and can anybody help with the 404 errors?

© Stack Overflow or respective owner

Related posts about html

Related posts about session