Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    May 2002
    Posts
    139

    Lightbulb redircting http:// to https://

    i have found a snipit that will redirect the visitor to the https:// page even if they try to access via the http://

    put this in the verry begining of the index.php file

    PHP Code:
    if ( !isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on' ) { 
       
    header ('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); 
       exit(); 


  2. #2
    Member
    Join Date
    Jun 2004
    Posts
    50

    Default

    why not setup a mod_rewrite in the .htaccess file? This is of course assuming you have mod_rewrite setup

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !443
    RewriteRule ^(.*)$ https://www.x.com/$1 [R,L]
    http://UserUnfriendly.com
    Hosting Done Right.

  3. #3
    Member
    Join Date
    Sep 2004
    Posts
    529

    Default

    It's always preferable to put such configs into the httpd.conf itself, if at all possible. htaccess is convenient, especially if you have no other options (ie, no access to httpd.conf), but if you have a choice, go for httpd.conf.

    LA-fro, I can't tell just from reading it whether your rewrite rule will work both with or without a trailing slash. I'm not sure if the default 'trailing slash fix' applies here.

    My rewrite rule to ensure that a directory is always accessed using ssl is very similar to yours... I just have
    Code:
    (/)?
    in front of your
    Code:
    (.*)
    That ensures that both slashes and no-slashes will work.

  4. #4
    Registered User prasath's Avatar
    Join Date
    Feb 2006
    Posts
    3

    Default redirecting

    Hi,
    i want http://domain.com to work just like http://www.domain.com. Right now its not working. How to configure. Any suggestions?

    Thanks,
    Prasath.

Similar Threads & Tags
Similar threads

  1. routing from http to https
    By ThadBry in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 12-21-2005, 11:17 AM
  2. http to https
    By stevejac in forum cPanel and WHM Discussions
    Replies: 8
    Last Post: 07-29-2005, 03:36 PM
  3. Redirect Http to Https
    By billau in forum cPanel and WHM Discussions
    Replies: 16
    Last Post: 10-26-2004, 09:12 PM
  4. directing http to https
    By ctbhost in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-10-2004, 07:46 AM
  5. https vs. http
    By SupermanInNY in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 12-14-2003, 09:29 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube