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

    Having a site running MODX Evo, I am writing a version that site, dedicated to smartphones. The version for smartphones will have different content (i.e. truely optimized and not only different CSS layouts).

    For the mobile version, I plan using a "m.thesite.ext" subdomain that redirects to some "http://thesite.ext/mobile" folder.

    Now, which is the most rational approach:
    A) make a second independant installation
    of MODX in the site's "/m" folder?
    or
    B) use the same MODX installation
    and use some redirections via .htaccess?

    given that:
    1) Both versions will use Friendly URLs.
    2) The ".www" and ".m" versions won't have the same structure,
    nor the same number of documents.
    3) The same alias friendly URL should be usable for documents
    of both versions.
    For instance, "http://www.thesite.ext/same-alias"
    should not prevent "http://m.thesite.ext/same-alias"
    to point another document.
    4) The option "Access path for friendly URL" is off.
    5) The site is currently about 10 pages and will probably grow
    to a maximum of 50 pages for each of the "www." and "m." versions.

    A priori, I believe that setting the (A) option would be easier, but I may be wrong.

    If both options are possible, is (B) a better choice for maintenance on the mid and long terms?

    Please don't forget that I'm telling about MODX Evolution.
    Thanks for your advices.
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      This would've been super easy with Revolution using Contexts... but with Evo?

      I've seen projects where they managed to (using complex rewrite rules) create some sort of tree hierarchy that would be split across domains, so it should be possible. That said, a separate installation would probably be easier to set up. But then again, that would mean your client has to login to 2 separate managers to edit their content and you would need to duplicate stuff that could've been stored in one place but shown on both sites (company name, contact details, news perhaps) - not the best user experience for your client.

      You probably don't want to hear this, but I would suggest using Revolution. tongue
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 15001
        • 697 Posts
        Hi Mark,

        Thanks for your answer. I tried Revo in the past and found that the learning curve was not worth for my needs.

        The client will be myself and login twice is not a real problem as the two versions are like two distinct websites.

        Yes, I opted for two separate installs.
        The mobile version is in the "/m".

        After some tests, I could find some settings that a priori seems working fine.

        Here's the content of .htaccess for the main site on localhost.
        The site in installed in xampplite/htdocs/domain.ext.
        On the remote server, the RewriteBase path is changed to "/".
        #Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /domain.ext/
        #AllowOverride all
        
        # Force “www.domain.ext” instead of just “domain.ext”
        # To activate only for the remote site.
        #RewriteCond %{HTTP_HOST} .
        #RewriteCond %{HTTP_HOST} !^www\.domain\.ext [NC]
        #RewriteRule (.*) http://www.domain.ext/$1 [R=301,L]
        
        # The Friendly URLs part
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]


        Here's the content of .htaccess in the "/m" subfolder on localhost.
        i.e. in xampplite/htdocs/domain.ext/m.
        #Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /domain.ext/m/
        #AllowOverride all
        
        # Exclude /m /fonts /modeles /img /assets and /manager directories from rewrite rules
        RewriteRule ^(m|fonts|modeles|img|manager|assets) - [L]
        
        # The Friendly URLs part
        RewriteCond %.{REQUEST_FILENAME} !-f
        RewriteCond %.{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]


        The important thing to note is that the names of all folders in which the sub-site picks ressources must be excluded from the rewrite.
        RewriteRule ^(m|fonts|modeles|img|manager|assets) - [L]

        That's done in the .htaccess that is located in the ".m" folder.

        The line can also be put in the .htaccess file at the root of the main site, but this is optional.

        I assume that by setting "on" the AllowOverride option, one could maybe put the RewriteRule that excludes folders only in the .htaccess of the main site; however, this has not been working for me, and the current solution suits me.

        EDIT - Bug 05/23/2013
        There is a bug in the .htaccess files posted above.
        In the /m folder of the mobile site, are some stylesheets which should be loaded into the pages of the mobile site.
        <base href="http://www.domain.ext/m/" />
        <link rel="stylesheet" type="text/css" href="styles.css" />

        Those stylesheets are not found, excepted if their name starts with a "m" character. [ed. note: Jul last edited this post 13 years, 4 months ago.]