SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2006
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Force back to HTTP (without S) for certain pages

    Hi there,

    I will really appreciate if someone could give me an advice on what to do. I have 2 pages of my site forced to HTTPS and of course every link in those two pages refers to HTTPS URLs. I would like to make the user redirects back to HTTP version of one page if the user clicks on page links.

    In summary I would like to get a change back to HTTPS for specific pages.

    What code should I use in each page?

    I really appreciate your help.
    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use a full url including the http:// then that will be used.

    Alternatively you could use the <base href=""> tag and be explicit when you want to use https://

  3. #3
    SitePoint Addict bimalpoudel's Avatar
    Join Date
    Feb 2009
    Location
    Kathmandu, Nepal
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Detect your protocol, and redirect to corresponding page. $_SERVER contains information about http or https protocol.
    If you don't find https there, it is http.

    Code:
    die(header('Location: https://domain/file.php'));
    or,

    Code:
    die(header('Location: http://domain/file.php'));
    Use full url to redirect, and die() to stop executing below the code.
    Bimal Poudel @ Sanjaal Framework over Smarty Template Engine
    ASKING INTERESTING QUESTIONS ON SITEPOINT FOURM

    Hire for coding support - PHP/MySQL

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2006
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi thank you for the input, I 'm sorry because made a typo error.

    I would like to get a change back to HTTP (without S) for specific pages.

    I just have this code in my pages toforce HTTPS

    PHP Code:
    <?php

    if($_SERVER['HTTPS'] != 'on') {
        
    header('Location: https://XXXXX/member/sign_in.php');
    }
    What code should I use in the pages where I want to force the HTTP (without S) ??


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •