We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11954
    • 58 Posts
    Quote from: OpenGeek at May 26, 2009, 06:13 PM

    Quote from: heimdall at May 26, 2009, 05:28 PM

    Hi, does this also work with subdomains? What changes would I need to make to the .htaccess for subdomains rather than seperate domains?
    The situation is the same. The issue is that session cookies in PHP are configured for specific domains or for the requested domain (if not specified). By default, whatever is in your php.ini will determine what these session cookies will use for the domain, and typically this is blank (i.e. use domain requested by client). To support all subdomains with one session, you can set the value of session.cookie_domain to .domain.tld -- this effectively means you will use the same session for any subdomain of domain.tld, including no subdomain and www. You can set this in your php.ini or, if your on shared hosting and your host allows it, in the .htaccess file via php_value.

    Hi, I was actually asking more generally if this multi-domain method works with subdomains as well, if so how do I configure it. Sorry if it’s dumb question but I have never understood all these rewrite rules, despite spending many many hours trying. huh
      • 11954
      • 58 Posts
      Please Help

      I need to set this up with one main domain www.high-roller-test.com and 7 subdomains; de.high-roller-test.com, es.high-roller-test.com, no.high-roller-test.com, fr.high-roller-test.com, it.high-roller-test.com, nl.high-roller-test.com and pt.high-roller-test.com

      At the mement I can’t even get this to work on my main domain :-(.

      I am running this all through xampp on my local PC and I have the following in my local hosts file:

      127.0.0.1 localhost
      127.0.0.1 www.high-roller-test.com
      127.0.0.1 high-roller-test.com
      127.0.0.1 de.high-roller-test.com
      127.0.0.1 es.high-roller-test.com
      127.0.0.1 no.high-roller-test.com
      127.0.0.1 fr.high-roller-test.com
      127.0.0.1 it.high-roller-test.com
      127.0.0.1 nl.high-roller-test.com
      127.0.0.1 pt.high-roller-test.com



      the following in my apache config file:
      <VirtualHost *>
      ServerName www.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName de.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName es.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName no.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName fr.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName it.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName nl.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>

      <VirtualHost *>
      ServerName pt.high-roller-test.com
      DocumentRoot "C:/Program Files/xampp/xampp/htdocs"
      </VirtualHost>





      I have added the tamplate variable host_url and added it to the relevant templates
      I have added the snippet http_host
      I have added and activated the plugin multisite

      I have put the following in each of the templates, "<base href="http://[!http_host!]/" />"

      I have created a folder under root in MODX called www.high-roller-test.com which has an alias and host_url value of high-roller-test-com


      I have put the following in my .htaccess:
      #Options +FollowSymlinks
      RewriteEngine On
      RewriteBase /

      ###
      # First be sure to rewrite the request to a unique domain
      RewriteCond %{HTTP_HOST} .
      RewriteCond %{HTTP_HOST} ^high-roller-test\.com [NC]
      RewriteCond %{HTTP_HOST} !^www\.high-roller-test\.com [NC]
      RewriteRule (.*) http://www.high-roller-test.com/$1 [R=301,L]

      # rewrite the homepage of each domain to index.html
      RewriteRule ^high-roller-test-com\.html$ /index.html

      # do the other magic: Rewrite the the requests to for MODx readable folders
      RewriteCond %{HTTP_HOST} high-roller-test\.com [NC]
      RewriteCond %{REQUEST_URI} !^/manager
      RewriteCond %{REQUEST_URI} !^/images
      RewriteCond %{REQUEST_FILENAME} index\.php [OR]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(index\.(html?|php)|high-roller-test-com)?(.*)$ index.php?q=/high-roller-test-com/$3 [L,QSA]

      # The Friendly URLs part for the rest (or the main domain)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


      So what am I doing wrong becuase it isn’t working? I can get the frongpage but none of the internal pages, also I would really appreciate someone telling me exactly what I need to put into the .htaccess file to add my subdomains.

        • 1611
        • 591 Posts
        You need to copy this rules for each (sub)domain with corresponding changes.
          • 11954
          • 58 Posts
          Quote from: Andrey at May 31, 2009, 08:54 AM

          You need to copy this rules for each (sub)domain with corresponding changes.

          Sorry but I don’t understand. These rules don’t even work for www.high-roller-test.com why would copying them help? What changes do I need for the subdomains, please tell me exactly what I need to change, think of it as mod rewrites for dummy’s smiley
            • 1611
            • 591 Posts
            Does anybody know how to make cross-site links, or share documents between sites?
              • 24531
              • 213 Posts
              please help, i try to get this to work with subdomains

              i got aiesec.ru which is main site and got
              ufa.aiesec.ru (which is subsite on subdomain)
              i got physical subdomain ufa.aiesec.ru (blank with blank htaccess)

              have setup everything according tutorial
              this is my modified htaccess

              # First be sure to rewrite the request to a unique domain
              RewriteCond %{HTTP_HOST} .
              RewriteCond %{HTTP_HOST} !^ufa\.aiesec\.ru [NC]
              RewriteCond %{HTTP_HOST} ^www\.ufa\.aiesec\.ru [NC]
              RewriteRule (.*) http://www.ufa.aiesec.ru/$1 [R=301,L]
              # rewrite the homepage of each domain to index.html
              RewriteRule ^ufa-aiesec-ru\.html$ /index.html
              # do the other magic: Rewrite the the requests to for MODx readable folders
              RewriteCond %{HTTP_HOST} ufa\.aiesec\.ru [NC]
              RewriteCond %{REQUEST_URI} !^/manager
              RewriteCond %{REQUEST_FILENAME} index\.php [OR]
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(index\.(html?|php)|ufa-aiesec-ru)?(.*)$ index.php?q=/ufa-aiesec-ru/$3 [L,QSA]


              it gets 500.

              when i change
              RewriteRule ^(index\.(html?|php)|ufa-aiesec-ru)?(.*)$ index.php?q=/ufa-aiesec-ru/$3 [L,QSA]
              to
              RewriteRule ^(index\.(html?|php)|ufa-aiesec-ru)?(.*)$ http://aiesec.ru/index.php?q=/ufa-aiesec-ru/$3 [L,QSA]

              it redirects but this is external redirect and exposes actual url which i defenitely do not want.
                • 1611
                • 591 Posts
                Try this:
                ###
                # First be sure to rewrite the request to a unique domain
                RewriteCond %{HTTP_HOST} .
                RewriteCond %{HTTP_HOST} ^aiesec\.ru$ [NC]
                RewriteCond %{HTTP_HOST} !^www\.aiesec\.ru[NC]
                RewriteRule (.*) http://www.aiesec.ru/$1 [R=301,L]

                # rewrite the homepage of each domain to index.html
                RewriteRule ^aiesec-ru\.html$ /index.html

                # do the other magic: Rewrite the the requests to for MODx readable folders
                RewriteCond %{HTTP_HOST} ^www\.aiesec\.ru$ [NC]
                RewriteCond %{REQUEST_URI} !^/manager
                RewriteCond %{REQUEST_URI} !^/images/([a-z0-9]{32})/.*\.(png|gif|jpe{0,1}g)$
                RewriteCond %{REQUEST_FILENAME} index\.php [OR]
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(index\.(html?|php)|aiesec-ru)?(.*)$ index.php?q=/aiesec-ru/$3 [L,QSA]

                ###
                # First be sure to rewrite the request to a unique domain
                RewriteCond %{HTTP_HOST} .
                RewriteCond %{HTTP_HOST} ^www\.ufa\.aiesec\.ru$ [NC]
                RewriteCond %{HTTP_HOST} !^ufa\.aiesec\.ru[NC]
                RewriteRule (.*) http://ufa.aiesec.ru/$1 [R=301,L]

                # rewrite the homepage of each domain to index.html
                RewriteRule ^ufa-aiesec-ru\.html$ /index.html

                # do the other magic: Rewrite the the requests to for MODx readable folders
                RewriteCond %{HTTP_HOST} ^ufa\.aiesec\.ru$ [NC]
                RewriteCond %{REQUEST_URI} !^/manager
                RewriteCond %{REQUEST_URI} !^/images/([a-z0-9]{32})/.*\.(png|gif|jpe{0,1}g)$
                RewriteCond %{REQUEST_FILENAME} index\.php [OR]
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(index\.(html?|php)|ufa-aiesec-ru)?(.*)$ index.php?q=/ufa-aiesec-ru/$3 [L,QSA]
                ################################################
                  • 24531
                  • 213 Posts
                  unfortunately, this rules also don’t work as expected, i contacted hoster’s support, waiting for reply.
                    • 24531
                    • 213 Posts
                    support said that rule loops infinitely.
                    how to prevent infinite loops?
                      • 24531
                      • 213 Posts
                      ok this was hoster specific issue.
                      thank you for this solution