We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13197
    • 21 Posts
    I have a newly installed, MODx, sample site. I have installed it into a subdirectory called ’modx’. I have edited my .htaccess file and switched on SEO friendly url’s.

    If I try to access a page directly it works OK. ie: http://www.lotwplantation.com/ajax.html

    However if I try to navigate using a link on that page the link will insert the /modx/ part of my file path. So it would become: http://www.lotwplantation.com/modx/ajax.html
    The resulting page is not accessible (404)

    The directory structure when viewing the site through the hosting companies cp is: /www/www/modx

    I have edited my .htaccess file aand it’s path is: /www/www/.htaccess
    The relevant code in the .htaccess file is as follows.
    # Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /modx
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /modx/index.php?q=$1 [L,QSA]


    I have also renamed the /modx/manager/.htaccess file to turn off rewrites for that folder.

    I am obviously doing something wrong! I have come across similar posts but none of the suggestions have worked for me.

    The hosting company is ICDSoft. The server is running RedHat Linux, PHP 5.2.5, MySQL 5.0.45 and I have installed MODx version 0.9.6.1. The issue affects a variety of browsers.

    I am very new to this, so apologies if this post is in the wrong forum, or I have failed to find the answer from the old posts.

    Any help would be greatly appreciated.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      With the RewriteBase directive you don’t add the modx part to the actual rewrite rule.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 13197
        • 21 Posts
        Thank you for your response. I have changed the .htaccess code to the following but I am still getting the same result. Have I misunderstood?
        # Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /modx
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
        
          • 3749
          • 24,544 Posts
          Quote from: itough at Feb 05, 2008, 09:45 AM

          Thank you for your response. I have changed the .htaccess code to the following but I am still getting the same result. Have I misunderstood?
          # Options +FollowSymlinks
          RewriteEngine On
          RewriteBase /modx
          
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
          


          Have you tried this?

          # Options +FollowSymlinks
          RewriteEngine On
          RewriteBase /
          
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
          


          If that doesn’t work, add the modx back in and try removing the comment (#) character in front of "Options +FollowSymlinks"

          Bob


            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 13197
            • 21 Posts
            Bob, Thanks for the reply. Unfortunately neither option worked. Andy
              • 2734
              • 165 Posts
              Hi there.
              Let me recap. You installed MODx in a Subdirectory called modx. Do you want the MODx contents accessible from your main URL, eg: http://www.lotwplantation.com/ or do you use this for testing and want http://www.lotwplantation.com/modx to access the MODx contents?
              If you want to do use http://www.lotwplantation.com/modx you should move the .htaccess into that directory. the .htaccess should be like the one from your previous post (see quote below).

              Quote from: itough at Feb 05, 2008, 09:45 AM

              Thank you for your response. I have changed the .htaccess code to the following but I am still getting the same result. Have I misunderstood?
              # Options +FollowSymlinks
              RewriteEngine On
              RewriteBase /modx
              
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
              


                • 13197
                • 21 Posts
                Hi, Glad you asked what I actually want to achieve, as I may be tackling this from completely the wrong angle, and your question has made me question my method.

                I would like to be able to have a live (non MODx) site at http://www.lotwplantation.com
                At the same time would like to develop a new site in the /modx folder
                I guess that whilst I am developing the site it does not matter that the url’s are all containing /modx
                When the MODx site is complete I wanted to be able to leave it in the /modx folder, but have it accessed via http://www.lotwplantation.com and for it to automatically generate http://www.lotwplantation.com style menus not http://www.lotwplantation.com/modx
                Is this not the correct method? Should I be developing in /modx with http://www.lotwplantation.com/modx in all the the urls and then move the whole site to / folder. Will MODx then be able to generate the correct http://www.lotwplantation.com urls?
                I hope that makes sense.

                Andy
                  • 2734
                  • 165 Posts
                  Yeah. Now i understand what you’re trying to achieve smiley
                  First of all you should make modx work inside its designated directory. One thing to do would be to move the .htaccess into the modx folder, since you don’t want to get people from your "regular" site being redirected accidentally to your development site.

                  So first you need a .htaccess inside www/modx/
                  # Options +FollowSymlinks
                  RewriteEngine On
                  RewriteBase /modx
                  
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]


                  If your development site is up to date and ready to be published, you can move it to your main domain. If you want to leave all modx related content inside the modx directory you’ll have to alter the .htaccess accordingly and put it into your main domain (www) folder. Something like this should do:
                  # Options +FollowSymlinks
                  RewriteEngine On
                  RewriteBase /
                  
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule ^(.*)$ /modx/index.php?q=$1 [L,QSA]


                  The other problem are the links generated by modx. You should alter your modx-base path accordingly, so that the links no longer contain /modx/ (when moving to the "live" environment)
                    • 13197
                    • 21 Posts
                    Thank you very much for the advice. I have to leave the office now, and will not get a chance to try this out for a day or two, but I’ll let you know how I get on. Andy
                      • 13197
                      • 21 Posts
                      I’ve just realized there is one bit of your instructions I am a bit unclear on. When you talk about altering the modx-base path are you referring to the path described in the manager interface:

                      1. manager/tools/configuration/interface & features/resource path
                      or
                      2. manager/tools/configuration/file manager/file manager path
                      OR
                      3. do you mean tinkering with the manager/includes/config.inc.php file?
                      If this last this is something I played with before and was certainly out of my depth!
                      I had written the following code in this file:
                      $base_url='http://www.lotwplantation.com/';
                      $base_path='/home/lotwplantation/www/www/modx/';
                      $site_url='http://www.lotwplantation.com/';
                      
                      // automatically assign base_path and base_url

                      But doing this always seemed to lose me access to all the modx functionality and all I got was content. It seemed that I was just getting the base path wrong.
                      If editing this file is likely to be necessary I’d appreciate any feedback.
                      If it is as simple as using the manager to edit the path as I described in 1 and 2 I should be OK.
                      Thanks again
                      Andy