boo_lolly Posted July 22, 2010 Share Posted July 22, 2010 As the title indicates, I'm looking for all the required config variable settings, htaccess conditions and rewrites, etc. Basically, I'm looking for all opinions and examples because I'm almost positive I'll miss something the first time. So far, I've reviewed and slightly understood the validity of the following solutions: http://codeigniter.com/forums/viewthread/86113/ http://stackoverflow.com/questions/1818869/htaccess-https-to-http I'm not sure which applies to me, since several options are available. But the kicker is that it's hosted on a client's GoDaddy shared hosting account, and for some reason, "index.php" in the url doesn't work... it MUST be "index.php?" in the url, otherwise it just brings up a "No input file specified" error. It's BS. Anyway can I get some assistance here? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/208512-force-https-with-htaccess-and-codeigniter-on-godaddy/ Share on other sites More sharing options...
petroz Posted July 29, 2010 Share Posted July 29, 2010 Show us your httaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/208512-force-https-with-htaccess-and-codeigniter-on-godaddy/#findComment-1092831 Share on other sites More sharing options...
sKunKbad Posted July 30, 2010 Share Posted July 30, 2010 1) Godaddy does offer a refund if you cancel. This is your smartest move, but I understand that it might be somebody elses website you are working on. 2) I normally force HTTPS inside a controller. It would be a rare situation that you would want to force HTTPS for an entire site, but in that case, you could just extend the Controller class with a MY_Controller class. Then you would create a constructor that checks if HTTPS is on, and if not redirect to the equivalent HTTPS page. For an example of forcing HTTPS inside an individual controller: public function __construct() { parent::__construct(); // force SSL is available // USE_SSL is defined in a hook - 1 is on and 0 is off if(USE_SSL != 0 && !isset($_SERVER['HTTPS'])) { $this->load->helper('string'); // secure_base_url() and url_suffix() come from an extension of the url helper. header("Location: " . secure_base_url() . trim_slashes( $this->uri->uri_string() ) . url_suffix(), TRUE, 301); exit; } } MY_url_helper.php: <?php /* * Since trying to access a secure URL can result in errors, * this function only creates a secure URL if the my_site_definitions_hook * has the setting for USE_SSL set to 1. */ function secure_base_url() { $CI = get_instance(); $url = $CI->config->slash_item('base_url'); if(USE_SSL === 1) { $url = substr($url, 0, 4).'s'.substr($url, 4); } return $url; } /* * This function checks if SSL is on for the current request, * and if it is, it makes a secure URL. This can be used to * load resources like stylesheets, images, or javascript * in a way that won't cause a partially secure warning in the browser. */ function if_secure_base_url() { $CI = get_instance(); $url = $CI->config->slash_item('base_url'); if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $url = substr($url, 0, 4).'s'.substr($url, 4); } return $url; } /* * This current_url function has been overridden because * the CI version doesn't allow for secure URLs. */ function current_url() { $CI = get_instance(); $url = $CI->config->site_url($CI->uri->uri_string()); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $url = substr($url, 0, 4).'s'.substr($url, 4); } return $url; } /* * This function allows for a more convenient way to * create dynamic URLs that will have the appropriate * URL suffix, as specified in the main config file. */ function url_suffix() { $CI = get_instance(); return $CI->config->item('url_suffix'); } /* End of file MY_url_helper.php */ /* Location: /application/helpers/MY_url_helper.php */ Quote Link to comment https://forums.phpfreaks.com/topic/208512-force-https-with-htaccess-and-codeigniter-on-godaddy/#findComment-1092913 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.