Hello ,

I'm noob in php world, and have one problem with open index page
always after tray open index.php on my site i got this

[url]http://[www.:.com]//www.mydomain.com/Index.php[/url]

please help me what is wrong ?

    looks like you tried to use a $_SERVER variable that isn't populated for whatever reason. Same thing with the port (the portion after the ":").

    What's the code you're using?

      i will tray install "Rayzz" clone , this is windows hosting,
      this is code where i have problem in config.inc.php

      $default_ports = array('https' => 443, 'http' => 80);
      $prefix = (!empty($_SERVER['HTTPS']) ? 'https' : 'http');
      $host = '';
      if (isset($_SERVER['HTTP_HOST'])) //some says that this might not be set in IIS
      		$host = $_SERVER['HTTP_HOST'];
      	else if (isset($_SERVER['SERVER_NAME']))
      		$host = $_SERVER['SERVER_NAME'];
      $CFG['site']['url'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
                             . $host
                             . str_replace(
      					   			array('common/', 'members/', 'admin/', 'cron/', 'rss/'),
      					   			'',
      								substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1)
      							);
      $CFG['site']['relative_url'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
                             . $host
                             . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1);
      $CFG['site']['current_url'] =  $prefix.
      								(($_SERVER['SERVER_PORT']!=$default_ports[$prefix]) ?
      								':'.$_SERVER['SERVER_PORT'] : '') . '://'
      								.$host
      								.$_SERVER['REQUEST_URI'];

      and whats is mean with this "//PATH_TRANSLATED is removed in SAPI version since PHP 5 or 4.3.2?? Don't use it for auto detection "
      i run on my Plesk PHP 5

        Anyone can help me with this ?

          What if your if() and elseif() statements aren't matched for the $host? You have an empty $host variable.

          As for the port, you shouldn't need to specify it. The default for http is 80, and https is 443. You shouldn't need to do [noparse]host.tld:port[/noparse], https://host.tld or http://host.tld would work.

            Ok, if I understand it should look like this ?

            $default_ports = array('https' => 443, 'http' => 80);
            $prefix = (!empty($_SERVER['HTTPS']) ? 'https' : 'http');
            $host = 'mydomain.tld :80';
            //if (isset($_SERVER['HTTP_HOST'])) //some says that this might not be set in IIS
            //		$host = $_SERVER['HTTP_HOST'];
            //	else if (isset($_SERVER['SERVER_NAME']))
            //		$host = $_SERVER['SERVER_NAME'];
            $CFG['site']['url'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
                                   . $host
                                   . str_replace(
            					   			array('common/', 'members/', 'admin/', 'cron/', 'rss/'),
            					   			'',
            								substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1)
            							);
            $CFG['site']['relative_url'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
                                   . $host
                                   . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1);
            $CFG['site']['current_url'] =  $prefix.
            								(($_SERVER['SERVER_PORT']!=$default_ports[$prefix]) ?
            								':'.$_SERVER['SERVER_PORT'] : '') . '://'
            								.$host
            								.$_SERVER['REQUEST_URI'];

              No, you could just add an "else" statement rather than removing code.

              if (isset($_SERVER['HTTP_HOST'])) //some says that this might not be set in IIS
              		$host = $_SERVER['HTTP_HOST'];
              	else if (isset($_SERVER['SERVER_NAME']))
              		$host = $_SERVER['SERVER_NAME'];
              else
                  $host = 'mydomain.com:80';

                This don't work :queasy: , i got again same [[url]www.:.com][/url] , but never mind, will delete this script.

                Anyway, thank you for tray help me bud 🙂

                  Write a Reply...