V
V
Vernal962018-12-24 21:34:08
PHP
Vernal96, 2018-12-24 21:34:08

Why do I get multiple database connections when using RewriteRule for CNC links?

The site uses CNC links, code from htaccess:

Options -Indexes
Options -Includes
Options +FollowSymlinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) ./?%{QUERY_STRING}

When using it, the request goes to index.php, which looks like this:
mb_internal_encoding("UTF-8");
require_once "lib/database_class.php";
require_once "lib/frontpagecontent_class.php";
require_once "lib/config_class.php";
$db = new DataBase();
$config = new Config();
$content = new FrontPageContent($db);
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
$path = parse_url($url, PHP_URL_PATH);
$path = strtolower(substr($path, 1));
$path = str_getcsv($path, "/");
$reg = "/^[0-9a-z-_]+$/i";
$tree = parse_ini_file("cache/tree.ini", true);
if (count($path) == 1) {
  switch ($path[0]) {
    case "": {
      echo $content->getHeader($config->r_main);
      echo $content->getContent($config->r_main);
      echo $content->getFooter($config->r_main);
      break;
    }
    case $config->r_catalog: {
      echo $content->getHeader($config->r_catalog);
      echo $content->getContent($config->r_catalog);
      echo $content->getFooter();
      break;
    }
    case $config->r_basket: {
      echo $content->getHeader($config->r_basket);
      echo $content->getContent($config->r_basket);
      echo $content->getFooter();
      break;
    }
    case $config->r_about: {
      echo $content->getHeader($config->r_about);
      echo $content->getContent($config->r_about);
      echo $content->getFooter();
      break;
    }
    case $config->r_news: {
      echo $content->getHeader($config->r_news);
      echo $content->getContent($config->r_news);
      echo $content->getFooter();
      break;
    }
    case $config->r_search: {
      if (isset($_SESSION["search"])) {
        echo $content->getHeader($config->r_search);
        echo $content->getContent($config->r_search);
        echo $content->getFooter();
        unset($_SESSION["search"]);
      }
      else {
        echo $content->getContent("404");
      }
      break;
    }
    default: {
      echo $content->getContent("404");
    }
  }

The problem is that I have a bunch of database connections going on:
101 Query	SET lc_time_names = 'ru_RU'
      101 Query	SET NAMES 'utf8'
      102 Connect	[email protected] on new-nkrep
      102 Query	SET lc_time_names = 'ru_RU'
      102 Query	SET NAMES 'utf8'
      103 Connect	[email protected] on new-nkrep
      103 Query	SET lc_time_names = 'ru_RU'
      103 Query	SET NAMES 'utf8'
      104 Connect	[email protected] on new-nkrep
      104 Query	SET lc_time_names = 'ru_RU'
      104 Query	SET NAMES 'utf8'
      106 Connect	[email protected] on new-nkrep
      106 Query	SET lc_time_names = 'ru_RU'
      106 Query	SET NAMES 'utf8'
      105 Connect	[email protected] on new-nkrep
      105 Query	SET lc_time_names = 'ru_RU'
      105 Query	SET NAMES 'utf8'
      107 Connect	[email protected] on new-nkrep
      107 Query	SET lc_time_names = 'ru_RU'
      107 Query	SET NAMES 'utf8'
      108 Connect	[email protected] on new-nkrep
      108 Query	SET lc_time_names = 'ru_RU'
      108 Query	SET NAMES 'utf8'
      109 Connect	[email protected] on new-nkrep
      109 Query	SET lc_time_names = 'ru_RU'
      109 Query	SET NAMES 'utf8'
      110 Connect	[email protected] on new-nkrep
      110 Query	SET lc_time_names = 'ru_RU'
      110 Query	SET NAMES 'utf8'
      111 Connect	[email protected] on new-nkrep
      111 Query	SET lc_time_names = 'ru_RU'
      111 Query	SET NAMES 'utf8'
      112 Connect	[email protected] on new-nkrep
      112 Query	SET lc_time_names = 'ru_RU'
      112 Query	SET NAMES 'utf8'
      113 Connect	[email protected] on new-nkrep
      113 Query	SET lc_time_names = 'ru_RU'
      113 Query	SET NAMES 'utf8'
      114 Connect	[email protected] on new-nkrep
      114 Query	SET lc_time_names = 'ru_RU'
      114 Query	SET NAMES 'utf8'
      115 Connect	[email protected] on new-nkrep
      115 Query	SET lc_time_names = 'ru_RU'
      115 Query	SET NAMES 'utf8'
      116 Connect	[email protected] on new-nkrep
      116 Query	SET lc_time_names = 'ru_RU'
      116 Query	SET NAMES 'utf8'
      117 Connect	[email protected] on new-nkrep
      117 Query	SET lc_time_names = 'ru_RU'
      117 Query	SET NAMES 'utf8'
      118 Connect	[email protected] on new-nkrep
      118 Query	SET lc_time_names = 'ru_RU'
      118 Query	SET NAMES 'utf8'
      119 Connect	[email protected] on new-nkrep
      119 Query	SET lc_time_names = 'ru_RU'
      119 Query	SET NAMES 'utf8'
      120 Connect	[email protected] on new-nkrep
      120 Query	SET lc_time_names = 'ru_RU'
      120 Query	SET NAMES 'utf8'
      121 Connect	[email protected] on new-nkrep
      121 Query	SET lc_time_names = 'ru_RU'
      121 Query	SET NAMES 'utf8'
      122 Connect	[email protected] on new-nkrep
      122 Query	SET lc_time_names = 'ru_RU'
      122 Query	SET NAMES 'utf8'
      123 Connect	[email protected] on new-nkrep
      123 Query	SET lc_time_names = 'ru_RU'
      123 Query	SET NAMES 'utf8'
      124 Connect	[email protected] on new-nkrep
      124 Query	SET lc_time_names = 'ru_RU'
      124 Query	SET NAMES 'utf8'
      125 Connect	[email protected] on new-nkrep
      125 Query	SET lc_time_names = 'ru_RU'
      125 Query	SET NAMES 'utf8'
      126 Connect	[email protected] on new-nkrep
      126 Query	SET lc_time_names = 'ru_RU'
      126 Query	SET NAMES 'utf8'
      127 Connect	[email protected] on new-nkrep
      127 Query	SET lc_time_names = 'ru_RU'
      127 Query	SET NAMES 'utf8'
      128 Connect	[email protected] on new-nkrep
      128 Query	SET lc_time_names = 'ru_RU'
      128 Query	SET NAMES 'utf8'
      129 Connect	[email protected] on new-nkrep
      129 Query	SET lc_time_names = 'ru_RU'
      129 Query	SET NAMES 'utf8'
      130 Connect	[email protected] on new-nkrep
      130 Query	SET lc_time_names = 'ru_RU'
      130 Query	SET NAMES 'utf8'

Please tell me what is causing this phenomenon and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
synapse_people, 2018-12-24
@synapse_people

yes
Architecture? -What is it?
Sorry)
In general, I don’t see [L] in the rule, which means it can just be a multiple redirect in a circle (including cached)
or loading the page by the browser in advance

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question