ndjustin20 Posted April 30, 2008 Share Posted April 30, 2008 Greetings! I am wondering if the ssl that I currently have installed in cpanl and centos would be able to encapsulate my entire domain. For instance, say a person goes to www.mydomainname.com or test.mydomainname.com or www.mydomainname.com/test.php or something like that. Is there a way to, no matter how they reference the domain, to ensure they reach the https:// site and not the standard http:// ? I know that you can do this individually using .htaccess by using the following: RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^(.*)$ https://mydomainname.com/$1 [R] but what I am wondering is if there is a way to do this via php or to change a setting inside apache or something so every time you go to mydomainname it will always be the https:// secured site. I have been looking around though can't seem to figure out how to accomplish this without redirecting each page individually. Oh...and the ssl cert I have installed is a wildcard cert so it is designed to work with sub domains from the master domain. You guys are awesome, Justin Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 30, 2008 Share Posted April 30, 2008 Like a redirect, you mean? <?php if(!isset($_SERVER['HTTPS'] || strtolower($_SERVER['HTTPS']) != 'on') { header("location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit; } ?> Quote Link to comment Share on other sites More sharing options...
ndjustin20 Posted April 30, 2008 Author Share Posted April 30, 2008 Ok so that would redirect using php....thank you very much........is there a way to not have to do this for every page though? I would think that there must be a way to encapsulate your whole domain without having to redirect each instance of the domain while including sub domains. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 30, 2008 Share Posted April 30, 2008 um....PHP is read via file, and you are asking that no matter what they call (PHP file, Image, etc) can PHP redirect? nope. that's Apache. PHP can only redirect when called. Quote Link to comment Share on other sites More sharing options...
ndjustin20 Posted April 30, 2008 Author Share Posted April 30, 2008 Ok that being said do you know how to do this? Quote Link to comment Share on other sites More sharing options...
ndjustin20 Posted April 30, 2008 Author Share Posted April 30, 2008 I actually have multiple domains on one server so I would actually have to use a redirect then or could I use apache to only reflect that one domain? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 30, 2008 Share Posted April 30, 2008 read this Quote Link to comment 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.