|
-
Nov 5th, 2009, 10:02 AM
#1
Re: HTTPS to HTTP
well, you are using OR wrong, but that isn't the only problem. proper syntax would be the same as using AND:
PHP Code:
if(condition || other_condition)
//or:
if($name == "david" || $name == "something_else")
but, remember that an OR means that either of these conditions can be true an the IF statement will trigger.
the other problem is the way you're trying to evaluate the host. look at the above code, then look at your edited code. $referer['host'] doesn't look at the protocol scheme -- it looks at the host. the host is equal to "mydomain.com" -- it wouldn't have the protol attached like you've tried to do. you could do something like:
PHP Code:
<?php $protocol = parse_url($url, PHP_URL_SCHEME); //save for later $host = parse_url($url, PHP_URL_HOST);
if($host != "mydomain.com && $host != "www.mydomain.com"){ header("Location: {$protocol}://www.mydomain.com/"); } ?>
that might be better for what you want?
-
Nov 5th, 2009, 11:50 PM
#2
Thread Starter
Member
Re: HTTPS to HTTP
Thank you everyone, I echo'd out the $host, which was www.mydomain.com but it kept redirecting rather then letting through www.mydomain.com or mydomain.com so I changed
PHP Code:
if($host != "mydomain.com" && $host != "www.mydomain.com"){
to just be
PHP Code:
if($host != "www.mydomain.com"){
As it should always be this generally and it works fine.
Unless they navigate to the site using http://mydomain.com in which case the first link they click on will redirect them, or if they use the search box on the homepage that will redirect them.
Thank you very much..... tried to give you rep kows after "spreading it round" but apparently I have to spread it more first.
Last edited by buffy; Nov 5th, 2009 at 11:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|