We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hello,

    i make multiple sub-domains instalation and i have some troubles...
    create a folder at the root of my Revo instalation where I keep all external files like template, css, js and img.
    and then insert the template by snipet

    [[includeFile? &phpfile=`sun/estemplate.html`]]

    in www.domain.com everything is OK, but in sub.domain.com i have no styles, js and img
    i have in my template: <base href="[[++site_url]]" /> and for root is http://www.domain.com and for sub is http://sub.domain.com
    how can i fix this?

      palma non sine pulvere
      • 24068
      • 4 Posts
      Hello

      i guess you are using one context for each subdomain. If so, you can set site_url in the Context Settings (Create New, Key: site_url, Value: http://sub.domain.com)

      but thats not the solution for your problem
        • 24068
        • 4 Posts
        What you could do is to use absolute paths for styles, js and img, and wahtsnotall you miss.
        • Hi,
          thanks for ideas smiley)
          here is my Context for sub-domain:



          here is ROOT .HTACCESS:

          Options +SymlinksIfOwnerMatch
          RewriteEngine On
          RewriteBase /
          
          RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
          RewriteRule .* - [F,L]
          
          RewriteRule ^(manager|assets)/*$ - [L]
          RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
          
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
          
          Options +SymlinksIfOwnerMatch
          RewriteEngine on
          RewriteCond %{HTTP_HOST} ^domain.com [NC]
          RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
          
          <Files *.html>
          SetOutputFilter DEFLATE
          </Files>


          here is HTACCESS for subdomain:
          Options +SymlinksIfOwnerMatch
          RewriteEngine On
          RewriteBase /
          
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
          
          <Files *.html>
          SetOutputFilter DEFLATE
          </Files>
          



            palma non sine pulvere
          • Quote from: pureppl at Jun 07, 2011, 08:01 PM

            What you could do is to use absolute paths for styles, js and img, and wahtsnotall you miss.

            yes, is work with absolute path...but general problem is when i try Include snippet for the template because i want to edit my template remote like static .html file smiley

            maybe the problem is it in IncludeFile:

            <?php
            if ( !isset($phpfile) || $phpfile == "" ) return "No file.";
            ob_start();
            include $phpfile;
            $ob_contents = ob_get_contents();
            ob_end_clean();
            return $ob_contents;
            


            but i can`t see in code something for path...
              palma non sine pulvere
              • 24068
              • 4 Posts
              Quote from: Kristalin at Jun 07, 2011, 08:57 PM

              Quote from: pureppl at Jun 07, 2011, 08:01 PM

              What you could do is to use absolute paths for styles, js and img, and wahtsnotall you miss.

              yes, is work with absolute path...but general problem is when i try Include snippet for the template because i want to edit my template remote like static .html file smiley

              maybe the problem is it in IncludeFile:

              <?php
              if ( !isset($phpfile) || $phpfile == "" ) return "No file.";
              ob_start();
              include $phpfile;
              $ob_contents = ob_get_contents();
              ob_end_clean();
              return $ob_contents;
              


              but i can`t see in code something for path...

              Just to understand that: In the template you do

              [[includeFile? &phpfile=`sun/estemplate.html`]]

              and `sun/estemplate.html` means a relative path, relative to the root-directory of the subdomain?


              • Just to understand that: In the template you do

                [[includeFile? &phpfile=`sun/estemplate.html`]]

                and `sun/estemplate.html` means a relative path, relative to the root-directory of the subdomain?

                yes, is relative path...i try with absolute, like:
                [[includeFile? &phpfile=`http://www.domain.com/sun/estemplate.html`]]

                but is not work
                  palma non sine pulvere
                  • 24068
                  • 4 Posts
                  Now i undersand what you want to do.

                  First of all: Including remote files via php core function include is very very very bad practise, its like creating an open door for security issues of all kinds. You should never ever do this. One exeption: You do absolutly know what you are doing and what the implications are.

                  Back to Topic:

                  One way can be:

                  <?php
                  if (empty($phpfile)) return 'No phpfile.';
                  $subdomainPath = $modx->getOption('subdomain_path', $modx->context->config, false);
                  if (empty($subdomainPath)) return 'No setting subdomain_path.';
                  $path = $subdomainPath.$phpfile;
                  if(!file_exists($path)) return 'File not found.';
                  ob_start();
                  include($path);
                  return ob_get_clean();
                  


                  If you are using this snippet, create a subdomain_path key in Context Settings with the value setted to the full filesystem path on the server to the root-directory of the subdomain (the directory where the .htaccess of your subdomain is). Dont set subdomain_path to a remote directory like http://mysub.domain.com/

                  EDIT:

                  I would not do it that way wink i would edit my templates via the modx-manager and a editor like codemirror (there is a package for codemirror in packet manager)
                  • Quote from: pureppl at Jun 07, 2011, 09:46 PM

                    Now i undersand what you want to do.

                    First of all: Including remote files via php core function include is very very very bad practise, its like creating an open door for security issues of all kinds. You should never ever do this. One exeption: You do absolutly know what you are doing and what the implications are.

                    Back to Topic:

                    One way can be:

                    <?php
                    if (empty($phpfile)) return 'No phpfile.';
                    $subdomainPath = $modx->getOption('subdomain_path', $modx->context->config, false);
                    if (empty($subdomainPath)) return 'No setting subdomain_path.';
                    $path = $subdomainPath.$phpfile;
                    if(!file_exists($path)) return 'File not found.';
                    ob_start();
                    include($path);
                    return ob_get_clean();
                    


                    If you are using this snippet, create a subdomain_path key in Context Settings with the value setted to the full filesystem path on the server to the root-directory of the subdomain (the directory where the .htaccess of your subdomain is). Dont set subdomain_path to a remote directory like http://mysub.domain.com/

                    EDIT:

                    I would not do it that way wink i would edit my templates via the modx-manager and a editor like codemirror (there is a package for codemirror in packet manager)

                    First THANK YOU, when i use your snippet everything (for now) work perfect smiley
                    for me is much more convenient to edit remote file smiley YEs, is not secure....but this file also is in same server...
                      palma non sine pulvere
                    • i have one mroe question about path`s for plugins and snippets...how make this everything work normal in sub-domains?

                      for example i use Captcha plugin and in root is work perfect, but in sub.domain.com i get:
                      Error: The captcha plugin must be installed to use captcha in spform.
                        palma non sine pulvere