We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53414
    • 34 Posts
    Actually I need to do this as well (convert site to https).  Using Modx Revo 2.5.7-pl.  Ive broken
    my site my editing my .htaccess files in trying to implement cute url's but generally got it back.
    However, now Modx gives me a warning that my core directory is available for anyone to view: which
    I presume is undesireable.
    
    If I disable the .htaccess file, then I cannot load the Modx manager.  It should permit control 
    by the Apache Server and is thus unecessary. However if I enable it, it seems to give everyone
    access to my core directory.  The contents of the .htaccess are as below.  Note I've change my
    domain to my-domain.      Finally I was preferring to use [u]my-domain.com[/u]  NOT www.my-domain.com
     You'll note there are differences between the .htaccess file referenced elsewhere in some of the coding  
    
    for example he has:
    code]#RewriteCond %{HTTP_HOST} !^clientdomain\.com [NC]

    while I have:
    RewriteCond %{HTTP_HOST} ^(www.)?my-domain.com$


    my .htaccess file located in /my-domain.com/www/
    # .htaccess main domain to subfolder redirect
    # Copy and paste the following code into the .htaccess file
    # in the public_html folder of your hosting account
    # make the changes to the file according to the instructions.
     
    # Do not change this line.
    RewriteEngine on
     
    # Change yourdomain.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?my-domain.com$
     
    # Change 'subfolder' to be the folder you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/modx/
     
    # Don't change this line.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
     
    # Change 'subfolder' to be the folder you will use for your main domain.
    RewriteRule ^(.*)$ /modx/$1
     
    # Change yourdomain.com to be your main domain again.
    # Change 'subfolder' to be the folder you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
     
    RewriteCond %{HTTP_HOST} ^(www.)?my-domain.com$
    RewriteRule ^(/)?$ modx/index.php [L]
    
    ErrorDocument 404 "<H1>Page 404 not finding</H1>"
      • 46886
      • 1,154 Posts
      Hi here is mine, my hoster recently helped me fix it, it writes everything to https. Also you absolutely need this file or I don't think you can serve any pages at all


      # Prevent Apache from serving .htaccess files:
      <FilesMatch "^\.htaccess">
          Order allow,deny
          Deny from all
      </FilesMatch>
      
      Options All -Indexes
      Options +FollowSymlinks
      
      RewriteEngine On
      RewriteBase /
      
      RewriteCond %{HTTP_HOST} domain\.com [NC]
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://domain.com/$1 [R,L]
      
      # The Friendly URLs part
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
      RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
      RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]



      But you will need to keep the re-write rules to use the subfolder as the main domain

        • 53414
        • 34 Posts
        Quote from: nuan88 at May 30, 2018, 09:42 PM
        Hi here is mine, my hoster recently helped me fix it, it writes everything to https. Also you absolutely need this file or I don't think you can serve any pages at all

        Thanks very much. I'm not commenting much on Modx menus now as I've percieved larger problems with my directory structure. For example I've no public_html directory and I've multiple core directories and multiple cache directories. Also my Modx system directories are all renamed to something in Albanian that I can never keep straight. After 8 mos of working with this developer, nothing works. The only working version of my site was years ago when it was all html + simple in-line css. I don't want to continue in-line css and would greatly prefer css style sheets or using modx. My site used to be many pages.

        It appears that due to the exposed modx core, or other problems, the w3.com has blacklisted my site so that I can no longer post images for public file viewing. Google chrome shows a red warning message saying that images from my website are blocked. I'm really desirous of simply erasing the whole thing and starting afresh. This is also why I cannot upload any pix to the forum.

        Just today I bought a SSL certif for my site thru my hosting Co for Comodo. I'll convert everything to https. Also I plan to use the rewrite for www.my-domain.com ==> my-domain.com It doesn't play to use these part time consultants, they don't explain anything and just create a giant mess of files which it takes forever to dechipher.

        Your example is good because I am currently using a server running with Apache. I'll send your example to my hosting people to see if they have any more site specific info for me. [ed. note: julius nepos last edited this post 5 years, 10 months ago.]
          • 46886
          • 1,154 Posts
          Hmm this sounds weird, but I don't know enough about server side stuff to help much.

          I do think you must have a public folder, but its possible you are on some sort of shared hosting?

          The SSL certificate is key, you have to get that installed and then the htaccess file should be ok.

          If you have folders in a foreign language you should change all of them, however you may have to change your paths in Modx.

          When Modx is all in a subfolder then I believe all files (css, components, core assets and so on) will be within that folder.

          If your installation is in a subfolder then you will need to include that re-write rule about the subfolder, what it does is sort of hide the real structure and so you can still get www.domain.com rather than www.domain.com/subfolder

          Yes cancel the www, I dont know why but I did apparently its the trend
            • 53414
            • 34 Posts
            Quote from: nuan88 at Jun 04, 2018, 12:45 AM

            Yes cancel the www, I dont know why but I did apparently its the trend
            Hi

            I got the following from Apache.org

            "In general, you should only use .htaccess files when you don't have access to the main server configuration file. There is, for example, a common misconception that user authentication should always be done in .htaccess files, and, in more recent years, another misconception that mod_rewrite directives must go in .htaccess files. This is simply not the case. You can put user authentication configurations in the main server configuration, and this is, in fact, the preferred way to do things. Likewise, mod_rewrite directives work better, in many respects, in the main server configuration.

            .htaccess files should be used in a case where the content providers need to make configuration changes to the server on a per-directory basis, ..."

            There seem to be no good references on directory structure. Always they're talking about super simple stuff like organize your 1,000 pix into subdirectories and provide descriptive subdirectories. However no mention on whether it should be my-domain.com/public_html/www/modx/core or anything else. As mentioned prev I have several core directories for modx & am wondering why. [ed. note: julius nepos last edited this post 5 years, 10 months ago.]