V
V
viktorross2019-07-26 13:00:03
PHP
viktorross, 2019-07-26 13:00:03

Why does the subdomain not work, redirect to the main page?

Why doesn't my autosubdomain work? More precisely, when opening a link, there is a stupid transfer to the main page ($ main_domain), the output

// SEF dealer page link
  function makeDealerLink($id, $dealer_name='', $page='', $canonical=0) {

    // subdomain dealer link
    global $ads_settings;
    $usr = new users();
    if($ads_settings['dealer_subdomain'] && $usr->allowStoreBanner($id)) { 
      $subdomain = $usr->getDealerSubdomain($id);
      
      global $main_domain; 
      $site_url = "http://".$subdomain.".".$main_domain;

      $page_str="";
      if($page) $page_str=$page."/";
      $dealer_link = $site_url."/".$page_str;
      
      return $dealer_link;
    }
    
    // non subdomain dealer link
    if($dealer_name) $url_dealer = _urlencode($dealer_name);
    else $url_dealer = _urlencode(users::getContactName($id));

    global $config_live_site;
    $site_url = $config_live_site;
    if($canonical) { global $main_domain; $site_url = "http://".$main_domain; }

    $page_str="";
    if($page) $page_str=$page."/";
    $dealer_link=$site_url."/".$id."-".$url_dealer."/".$page_str.$this->links["store"];

    return $dealer_link;

  }

  // SEF dealer page link
  function makeUserListingsLink($id, $dealer_name='', $page='', $canonical=0) {

    if($dealer_name) $url_dealer = _urlencode($dealer_name);
    else $url_dealer = _urlencode(users::getContactName($id));

    global $config_live_site;
    $site_url = $config_live_site;
    if($canonical) { global $main_domain; $site_url = "http://".$main_domain; }
    $page_str="";
    if($page) $page_str=$page."/";
    $dealer_link=$site_url."/".$id."-".$url_dealer."/".$page_str.$this->links["user_listings"];

    return $dealer_link;

  }

another file has this
// if seo urls
if($seo_settings['enable_mod_rewrite']) {
  global $settings;
  $contact_name_field = $settings['contact_name_field'];
  if(isset($user[$contact_name_field]) && $user[$contact_name_field])
     $paginator->setSeoUrlStr($id."-"._urlencode($user[$contact_name_field]));
  else $paginator->setSeoUrlStr($id."-"._urlencode($user['username']));
  $paginator->setExcludeArray(array("id"));
}

in fact, the link itself is generated, but from the created subdomain there is a redirect to the main page
in htaccess there is this, it used to work for auto-subdomains of cities, according to the same principle
RewriteCond %{HTTP_HOST} !www.site.ru$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-_]+).site.ru [NC]
RewriteRule (.*) %{SCRIPT_FILENAME}?crt_city=%2 [NC,QSA]

I tried this way the site opens without www, it costs a redirect from www to the usual https://site.ru - perhaps this is the reason .. instead of subdomain, I substituted the subdomain that should be created, after that the subdomain address opens with the main page of the site and that's it .. page which was supposed to be not working what could be the problem? I don't see any errors in the log
RewriteCond %{HTTP_HOST} !subdomain.site.ru$ [NC]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2019-07-26
@ThunderCat

Remove unnecessary TL;DR
tags.
1) Place wardump and exit at key points of the code, see how the execution is going and where it works wrong
2) Open the network panel in chrome and see what headers come to the redirect.
3) Disable/enable redirect directives in xtaxes.
In short, perform a classic debug.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question