Reply to Re: [PHP] turn off the www

Your name:

Reply:


Posted by Jochem Maas on 06/30/05 02:14

[top posting out of spite] ;-)

I'm guessing that the OP is only dealing with 1 domain?
why not...

<?
// define in a handy config file?
define('BASE_DOMAIN', 'yourdomain.com');


if($HTTP_SERVER_VARS['HTTPS'] != 'on') {
header('location: https://'.BASE_DOMAIN.$_SERVER["REQUEST_URI"]);
}

?>

....only single quotes for extra speed :-) and no extraneous $newurl var either.

John Nichel wrote:
> Ross wrote:
>
>> now.....
>>
>> I am using the following code to turn http into https and get my ssl
>> working.
>>
>> if($HTTP_SERVER_VARS["HTTPS"] != "on")
>> {
>> $newurl = "https://" . $_SERVER["SERVER_NAME"] .
>> $_SERVER["REQUEST_URI"];
>> header("location: $newurl");
>> }
>>
>>
>> However I set the ssl up on http://mydomain.com not
>> http://www.mydomain.com
>> and it give me a warning which I do not want the users to see.
>>
>> Can I do someting to make any page automatically redirtect as above using
>> https WITHOUT the www in this format
>>
>> https://mydomain.com
>
>
> $newurl = "https://" . preg_replace ( "/^www\./i", "",
> $_SERVER["SERVER_NAME"] ) . $_SERVER["REQUEST_URI"];
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация