- 论坛徽章:
- 0
|
原帖由 lwbbs 于 2007-6-1 08:39 发表
在每个文件前面加上或include下面的内容:
- <?php
- if (strcasecmp(substr($_SERVER["SERVER_URL"], 0, 5), "https") != 0)
- {
- $url = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
- header($url);
- }
- //continue
- ?>
复制代码
看<pre><? print_r($_SERVER) ?></pre>的结果,怎么没有看到$_SERVER["SERVER_URL"]这条?
- Array
- (
- [HTTP_HOST] => xxoo.com
- [HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11
- [HTTP_ACCEPT] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
- [HTTP_ACCEPT_LANGUAGE] => zh-cn,zh;q=0.5
- [HTTP_ACCEPT_ENCODING] => gzip,deflate
- [HTTP_ACCEPT_CHARSET] => x-gbk,utf-8;q=0.7,*;q=0.7
- [HTTP_KEEP_ALIVE] => 300
- [HTTP_CONNECTION] => keep-alive
- [HTTP_COOKIE] => flags=3ed; __utma=234433546.396199948.1177563626.1177563626.1177563626.1; dbx-postmeta=grabit:0+|1-|2-|3-|4-|5-&advancedstuff:0-|1-|2-; style=null; cdb_cookietime=2592000; dbx-linkmeta=grabit:0+|1-|2-&advancedstuff:0-|1-; dbx-pagemeta=grabit:0-|1-|2-|3+|4-|5-|6-|7-&advancedstuff:0-; __utmz=234433546.1177563626.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
- [HTTP_CACHE_CONTROL] => max-age=0
- [PATH] => /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
- [SERVER_SIGNATURE] =>
- Apache/2.0.52 (CentOS) Server at xxoo.com Port 80
- [SERVER_SOFTWARE] => Apache/2.0.52 (CentOS)
- [SERVER_NAME] =>xxoo.com
- [SERVER_ADDR] => 10.1.16.32
- [SERVER_PORT] => 80
- [REMOTE_ADDR] => 10.1.34.33
- [DOCUMENT_ROOT] => /var/www/html
- [SERVER_ADMIN] => xxoo@xxoo.com
- [SCRIPT_FILENAME] => /var/www/html/play.php
- [REMOTE_PORT] => 2389
- [GATEWAY_INTERFACE] => CGI/1.1
- [SERVER_PROTOCOL] => HTTP/1.1
- [REQUEST_METHOD] => GET
- [QUERY_STRING] =>
- [REQUEST_URI] => /play.php
- [SCRIPT_NAME] => /play.php
- [PHP_SELF] => /play.php
- [REQUEST_TIME] => 1180663984
- [argv] => Array
- (
- )
- [argc] => 0
- )
复制代码 |
|