We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12241
    • 80 Posts
    Okay, I moved the site to the production server and set everything up with the above .htaccess code for hiding the subdirectory works! The manager logs in perfectly. Sorry for any confusion I’m not sure why I was experiencing this problem on my local environment, maybe a caching thing or something smiley

    Anyways, if the person who started this thread is still paying attention the answer is found in this .htaccess code (placed in the ROOT directory of your site)
    #RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www\.)?top-level-domain\.org$
    RewriteCond %{REQUEST_URI} !^/subdirectory/
    RewriteRule ^(.*)$ subdirectory/$1 [L]
    


    wink -Aaron
      Environment:
      modx: rev 2.0.8-pl
      localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37
      • 6179
      • 4 Posts
      Thanks Aaron, that did the trick.
        • 6564
        • 8 Posts
        I hope one of you geniuses can help me!

        I am running revo, not that I think it makes a difference with my query
        I have hosting website unlimitedwebhostinguk.co.uk with a automated hosting script running in the root folder and modx running in subfolder ... basically i want my modx links to look like they not running in a subfolder. The main problem is so that the script I have isn’t affected by the .htaccess

        This is the scripts .htaccess

        <IfModule mod_ssl.c>
        RewriteBase /unlimitedwebhostinguk.co.uk/
        </IfModule>
        <IfModule !mod_ssl.c>
        RewriteBase /
        </IfModule>
        RewriteEngine On
        RewriteRule ^([^.]*)$ index.cgi/$1 [L,NE]
        RewriteEngine On
        RewriteRule ^([^.]*)$ index.cgi/$1 [L]

        thanks for the help in advance!!!
          • 20371
          • 58 Posts
          I’m trying to get a subfolder structure working and found this thread really helpful.. for something I thought would be simple - this is giving me some grief.

          Aarons .htaccess rewrite rules worked for me... after 1 change, uncomment the first line so its:
          RewriteEngine On
          RewriteBase /
          RewriteCond %{HTTP_HOST} ^(www\.)?top-level-domain\.org$
          RewriteCond %{REQUEST_URI} !^/subdirectory/
          RewriteRule ^(.*)$ subdirectory/$1 [L]
          

          wink

          So... to my next problem:
          wayfinder is still generating url’s like ’top-level-domain.org/subdirectory/foobar’
          so you could type ’top-level-domain.org/foobar’ into your browser bar and it would work... but any links wayfinder generated on that page would contain ’subdirectory’

          Things I’ve tried:
          -adding ’<BASE href="top-level-domain.org" />’ to my <HEAD> - no joy.
          -clearing cache (a lot of times.. just out of frustration)
          -changing RewriteBase in /foobar/.htaccess (doesn’t seem to do anything at all?!)

          to my naive understanding the problem must be to do with [(site_url)], its being detected correctly.. because the site is indeed located at "top-level-domain.org/subdirectory/" .. its just that I want it to think its "top-level-domain.org"

          Any thoughts?
            • 6564
            • 8 Posts
            Quote from: darkestar at Feb 20, 2011, 02:04 AM

            I hope one of you geniuses can help me!

            I am running revo, not that I think it makes a difference with my query
            I have hosting website unlimitedwebhostinguk.co.uk with a automated hosting script running in the root folder and modx running in subfolder ... basically i want my modx links to look like they not running in a subfolder. The main problem is so that the script I have isn’t affected by the .htaccess

            This is the scripts .htaccess

            <IfModule mod_ssl.c>
            RewriteBase /unlimitedwebhostinguk.co.uk/
            </IfModule>
            <IfModule !mod_ssl.c>
            RewriteBase /
            </IfModule>
            RewriteEngine On
            RewriteRule ^([^.]*)$ index.cgi/$1 [L,NE]
            RewriteEngine On
            RewriteRule ^([^.]*)$ index.cgi/$1 [L]

            thanks for the help in advance!!!


            Can anyone help me with this please?
              • 20371
              • 58 Posts
              @darkestar

              I dont really know what I’m talking about but..

              It sounds like you have a root directory with a modx folder and a bunch of other stuff so when you use the rewrite script here it makes modx work but the other stuff on your site isn’t accessible anymore.

              I think the idea is that you need to make RewriteCond conditions to exclude whatever you dont want rewritten..

              so if your domain is ’shizzle.com’ and your root folder is:
              .
              ..
              modx/
              foobar.htm
              someFolder/
              


              then your modrewrite rule would be something like:

              RewriteEngine On
              RewriteBase /
              RewriteCond %{HTTP_HOST} ^(www\.)?shizzle\.com$
              RewriteCond %{REQUEST_URI} !^/modx/
              RewriteCond %{REQUEST_URI} !^/foobar\.htm
              RewriteCond %{REQUEST_URI} !^/someFolder/
              RewriteRule ^(.*)$ modx/$1 [L]
              


              I think the !^ in the RewriteCond basicly means "dont match this", so if a url like shizzle.com/foobar.htm is requested it wont be matched and therefore wont be rewritten.

              no guarantees it will work, but that’s what I’d try. (unless I’ve completely misunderstood your problem.. sorry)
                • 6564
                • 8 Posts
                Thanks for you reply ... it felt a bit like ghost town.

                Let me explain whats happening

                I have a script that is running in the root folder:

                unlimitedwebhostinguk.co.uk

                Now I have the rest of the pages for the website running through modx on a subfolder called /modx/... at the moment when I call these page I have to call them
                e.g.: unlimitedwebhostinguk.co.uk/modx/hosting.html

                As soon as I add modx .htaccess script to the root .htaccess the "modx" in the url disappears and everything works except for the script stops working in the root -- if this makes any sense.

                - Firstly the script .htaccess running in the roots is the one I showed you above.
                - I need a way to get both working at the same time.
                  • 20371
                  • 58 Posts
                  Oh I see..

                  I don’t know if there -is- a way to do what you want.

                  the approach used by both your script -and- modx is to pass everything after ’shizzle.com/’ as arguments to your script’s index.cgi and modx’s index.php.

                  Using rewrite rules you can seperate out files, folders, (or specific arguments.. I guess) so they will not be rewritten, but you need to specify which things to rewrite, or not to rewrite. In your case that would be difficult, (impossible?)
                  ie: if the url:
                  shizzle.com/someargument
                  is requested, how can you tell your rewrite rules to route that to:
                  shizzle.com/modx/index.php?someargument
                  -or-
                  shizzle.com/index.cgi?someargument
                  you need someway to specify which url’s go to which script. The only way I can see to do that in a rewrite script would be to list every possible url/request which you do not want rewritten.. an arduous task.

                  Is it possible to move the script in the root folder to a subfolder?

                  What is the script running in the root folder? can you post index.cgi?
                    • 6564
                    • 8 Posts
                    You are correct, however I won’t ever refer to the homepage on the modx side only the index.cgi will be the home directory. Is there may be a way to do that?