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

    Just wanna know, whether someone can help me clarify things up.

    Thank you...
      Wendy Novianto
      [font=Verdana]PT DJAMOER Technology Media
      [font=Verdana]Xituz Media
      • 32963
      • 1,732 Posts
      Quote from: wendy at Nov 21, 2005, 08:23 PM

      Bump!!

      Just wanna know, whether someone can help me clarify things up.

      Thank you...

      Hi wendy,

      What is it that you need to be clarify?

        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 32241
        • 1,495 Posts
        xwisdom...

        I tried to modified your code, and it ended up not doing what I want it to be. With the Location header, it will only redirect the user, and it will change the url to the user.

        Here is the code:
        $e = &$modx->event;
        // Main Site Domain
        $mainSiteDomain = 'main.domain.com';
        // Sub Sites Configuration Array
        $subSites[0]['domain'] = 'subdsite.domain.com'; // SubSite Domain (Mirrored to MODx installation domain)
        $subSites[0]['alias'] = 'subdsite'; // SubSite Folder Document Alias
        $subSites[0]['id'] = 6; // SubSite Folder Document ID
        $subSites[0]['error'] = 7; // Error Page ID
        
        if($e->name=='OnWebPageInit') {
          // Extract Domain and URI
          $incomingDomain = $_SERVER['HTTP_HOST'];
          $incomingPath = $_SERVER['SCRIPT_NAME'];
          $incomingQueryString = $_SERVER['QUERY_STRING'];;
          // Checking subSites Array and directing users to the right start page
          for($i = 0; $i < count($subSites); $i) {
            if($incomingDomain==$subSites[$i]['domain'] && !isset($domainRedirectSign)) {
              //$modx->config['site_start'] = $subSites[$i]['id']; // start page here
              //$modx->config['error_page'] = $subSites[$i]['error']; // error page here
              header('Location: http://'.$mainSiteDomain.'/'.$subSites[$i]['alias'].$incomingPath.'?'.$incomingQueryString.'&domainRedirectSign=1');
              exit;
            }
          }
        }
        


        Basically I’m trying to change all the address into the main.domain.com/subsite/URI_REMAINING_ADDRESS. I assume that each subsite will be aliased and using all the SEO tools provided by MODx.
        The current solution that doesn’t fit me is the appearance of subsite on the subdomain. Instead of having subsite.domain.com/home, it will show up as subsite.domain.com/subsite/home.

        Is there anyway to use mod rewrite engine to determin the requested domain and rewrite it to the maindomain/subsitefolder?


        Sincerely,
        Wendy Novianto
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media
          • 32241
          • 1,495 Posts
          I’ve been researching about mod-rewrite, and here is what I come up with, I just make a subfolder under my main modx folder, and create a new subfolder again for my other subdomain/domain. In each subfolder, I will have .htaccess file to control the redirection for that subdomain/domain.

          Here is what the folders looks like
          modx/
          assets/
          manager/
          subsites/
          subdomain1.domain.com/
          .htaccess
          domain2.com/
          .htaccess
          index.php
          .htaccess

          Inside the .htaccess of each sub sites I paste this code: (ex: subdomain1.domain.com)
          RewriteEngine on
          RewriteCond %{HTTP_HOST} ^subdomain1.domain.com$ [OR]
          RewriteCond %{HTTP_HOST} ^www.subdomain1.domain.com$
          RewriteRule ^(.*)$ http://main.domain.com/subdomain1.domain.com/$1 [L,QSA]
          


          I’m assuming that all the SEF options are being activated. The way how the subsites was organized inside the MODx is by seperating them in different directories and aliased the main directory of the subsites into its domain name, for example "subdomain1.domain.com".

          So far it works just fine, but I’m having the same problem with the previous one, which is url address on the web browser is changing, from "http://subdomain1.domain.com/home.html" into "http://main.domain.com/subdomain1.domain.com/home.html".

          Any other idea or solution? This is areally hacky solution, if xwisdome or somebody else able to handle this in more MODx way, please do so. The one that xwisdome came up with is a really good solution, except, the "subdomain1.domain.com" is being included on every subsites. So in my example above, the result will look like this, from "http://subdomain1.domain.com/home.html" into "http://subdomain1.domain.com/subdomain1.domain.com/home.html".

          If the middle part of "subdomain1.domain.com" can be removed, than it will be awesome....

          Thank you guys


          Sincerely,
          Wendy Novianto

          Btw, don’t use the code given above, it’s not working correctly.

            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 32963
            • 1,732 Posts
            Quote from: wendy at Nov 22, 2005, 11:29 PM

            xwisdom...

            I tried to modified your code, and it ended up not doing what I want it to be. With the Location header, it will only redirect the user, and it will change the url to the user.

            Hi Wendy,

            You code aboves does exactly what it was coded to do. It will only redirect the user the the address specified.

            What I think you’re trying to do is have the system "Transfer" all request for a subdomain to subdomain/subsite folder, correct? This solution (I think) can only be accomplished via mod_rewrite.
              xWisdom
              www.xwisdomhtml.com
              The fear of the Lord is the beginning of wisdom:
              MODx Co-Founder - Create and do more with less.
              • 32241
              • 1,495 Posts
              Quote from: xwisdom at Nov 23, 2005, 09:24 AM

              Hi Wendy,

              You code aboves does exactly what it was coded to do. It will only redirect the user the the address specified.

              What I think you’re trying to do is have the system "Transfer" all request for a subdomain to subdomain/subsite folder, correct? This solution (I think) can only be accomplished via mod_rewrite.

              That’s so true xwisdom. After spending 5 hours last night, I can’t think of any other way to hide the main domain redirection, as well as the the alias path, that is why I’m settling up with those solution aboved, which use empty folder and place htaccess on it, the only problem is, I couldn’t get the modrewrite engine to hide the url. It’s succesfully transfer the request to the main domain, but the address in URL was changed as well.

              My knowledge of ModRewrite and Regular Expression is very limited, so if you can help me with this, it will be great.

              Thank you


              Regards,
              Wendy Novianto
                Wendy Novianto
                [font=Verdana]PT DJAMOER Technology Media
                [font=Verdana]Xituz Media
                • 29635
                • 361 Posts
                Hi Raymond and Wendy,
                I’ve read and reread the posts and still am not sure I’m on the same page:

                Wendy, is what you’re looking to do to strip the "subdomain" alias from the alias path, so instead of:
                subdomain1.domain.com/subdomain1/folder/content.html
                it reads:
                subdomain1.domain.com/folder/content.html?
                It seems like using individual physical subdomain folders with individual htaccess files only compounds the problem, but I could be totally wrong.

                Raymond, if that’s the case (above), is that something that could be put into a plugin? A mod rewrite could redirect, but MODx would still generate the links with that redundant alias path...

                I could be totally misunderstanding the whole situation though! smiley
                -Brett
                  Need MODx Ecommerce? Try FoxyCart!
                  • 32963
                  • 1,732 Posts
                  Hi Brett,

                  I think it’s possible for mod_rewrite to redirect and then you can use a plugin to process the redirected url.

                  The problem is finding a way for mod_rewrite to redirect the page to modx so the plugin can work on it.

                  I’m not a mod_rewrite expert.
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.
                    • 32241
                    • 1,495 Posts
                    Quote from: The at Nov 23, 2005, 10:46 AM

                    Raymond, if that’s the case (above), is that something that could be put into a plugin? A mod rewrite could redirect, but MODx would still generate the links with that redundant alias path...

                    To clarify things, do you mean it like this

                    For example we have:
                    - I setup a directory (dir id = 2) under the root dir, and set an alias to be "subdomain".
                    - All the documents/folders listed under doc/dir id 2 will be the sub sites content.
                    - I setup "subdomain.domain.com" to mirrored "domain.com"

                    With the plugin given above by xwisdom, when the user called "subdomain.domain.com" in their url, it will return a different starting page with the "domain.com". Later after that, when you follow the relative link on "subdomain.domain.com", it will do the same thing as "domain.com", which means, "subdomain.domain.com/subdomain/home.html" will be the same as "domain.com/subdomain/home.html", except the one on subdomain.domain.com has a different config of start_page and error_page.

                    If you’re looking for this kind of solution, the plugin is done, and it was listed on top of this post.

                    But what I’m looking for is the one that you stated, which is to removed the subdomain part, if they are accessing the page using "subdomain.domain.com". So instead of "subdomain.domain.com/subdomain/home.html", they will have "subdomain.domain.com/home.html", but if they use "domain.com", then it will be "domain.com/subdomain/home.html".

                    The solution that I come up with is using mod_rewrite, to rewrite the "subdomain.domain.com/home.html" into "domain.com/subdomain/home.html".

                    Hope that clear things up.
                    I know I’m not that good at explaining something, so pardon me, if it sounds confusing to some of you guys.


                    Sincerely,
                    Wendy Novianto
                      Wendy Novianto
                      [font=Verdana]PT DJAMOER Technology Media
                      [font=Verdana]Xituz Media
                      • 13207
                      • 59 Posts
                      This all sounds interesting. I’m a ModX newbie so some of this is currently over my head. Have just installed ModX for the first time.
                      Wanting to have one ModX install for all my separate domains that I have on one server I maintain (not subdomain.domain.com but where each domain is unique - domain1, domain2, etc.). All the verbage on subsites is a little confusing and sounds like it’s still being worked out. I assume that will need to use mod_rewrite and .htaccess. Is there any more documentation on what I want to do?