We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20765
    • 90 Posts
    myfriendscallmebill Reply #51, 20 years, 1 month ago
    Quote from: OpenGeek at Aug 23, 2006, 09:06 AM

    The path should be from the document root of the web server, which I would think would simply be...

    RewriteRule ^(.*)$ /mysubdirectoryname/index.php?q=$1 [L,QSA]

    That it works on your configuration that way has me wondering how, and does it not work with the path simply specified from the document root?

    I had to wait until after hours to try alternatives. I tried:
    subdirectory/index.php?q=$1 [L,QSA]
    /subdirectory/index.php?q=$1 [L,QSA]
    public_html/subdirectory/index.php?q=$1 [L,QSA]
    /public_html/subdirectory/index.php?q=$1 [L,QSA]
    username/public_html/subdirectory/index.php?q=$1 [L,QSA]
    /username/public_html/subdirectory/index.php?q=$1 [L,QSA]
    home/username/public_html/subdirectory/index.php?q=$1 [L,QSA]
    /home/username/public_html/subdirectory/index.php?q=$1 [L,QSA]

    All variations except the last one returned an Apache "Internal Server Error" message.

    I noticed this line in the .htacccess file:
    AuthUserFile "/home/username/.htpasswds/subdirectory/passwd"

    Could that have something to do with it?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If I recall my long-ago sysadmin days, it can depend on your server’s configuration. Usually the / means the start of your web root, but not always. Whatever works!
        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
        • 30223
        • 1,010 Posts
        No that has nothing to do with it. The AuthUserFile contains a list of usernames when you use password protection of directories on the apache level.

        Usually the document root on shared hosting is made relative to your domain but the actual path may be quite different so when you type in <domain>/whatever this internally get’s translated into (in your case) /home/username/public_html/whatever. Simply put in most cases rewrite rules only need to be concerned about anything beyond the document root but curiously in your case the full path is necessary. I wouldn’t worry about this though. It works evidently.

          • 727
          • 502 Posts
          I’m having a problem getting this to work. I’ve tries various suggestions with no luck. Hopefully someone can help me!

          Friendly URL settings:
          Use Friendly URLS: yes
          Prefix for friendly URLs: <blank>
          Suffix for friendly URLS: .html
          Use Friendly Aliases: yes
          Use Friendly Alias Path: no
          Allow Duplicate Aliases: no
          Automatically Generate Alias: no

          All of my templates have:

          <base href="[(site_url)]" />


          My .htaccess file looks like this:

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


          I’ve tried adding:

          RewriteBase /


          and using:

          RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]


          with no change to the behaviour.

          I have a set of pages that are stored in a subfolder called "locations". Some of these work and some don’t. It seems to be random and always changing, i.e. the links are not reliable. For example, clicking on:

          http://www.beverleyinpictures.co.uk/countyhall.html


          results in the following URL being used, which goes back to my home page:

          http://www.beverleyinpictures.co.uk/map.html?refurl=%2Findex.php%3Fq%3Dcountyhall.html&err=1


          To see this problem go to: http://www.beverleyinpictures.co.uk/locations.html then click on one of the "Learn More" links. From there click on the locations in the boxes on the right. Very quickly you will see the problem.

          I would greatly appreciate any help. Thanks!!

          Andy
            • 727
            • 502 Posts
            I added some logging to a file to see what is going on with my problem. Around line 1018 in document.parser.class.inc.php I have:

            write_to_log("docmethod=".$this->documentMethod."\n");
                  $this->documentIdentifier = $this->getDocumentIdentifier($this->documentMethod);
            write_to_log("docid=".$this->documentIdentifier."\n");
            


            At the start of getDocumentIdentifier I have:

              function getDocumentIdentifier($method) {
            write_to_log("getdocid, method=".$method."\n");
                // function to test the query and find the retrieval method
            


            The output I have is:

            docmethod=alias
            getdocid, method=alias
            docid=railwaystreet.html
            getdocid, method=id
            getdocid, method=id
            


            and at this point it calls sendErrorPage and redirects to:

            http://www.beverleyinpictures.co.uk/map.html?refurl=%2Findex.php%3Fq%3Drailwaystreet.html&err=1
            


            So it seems that for some reason once in a while getDocumentIdentifier is called three times in a row. The first time it fully executes and returns the correct document id, and then is called twice more but with the method "id", which is wrong, because it is using an alias. When it is called the second and third times the write_to_log() function call just before it is not executed, so this is like some kind of echo.

            The version of PHP is 4.4.1.

            Any ideas what the problem could be? I’m stumped but I need to get this working. Thanks!

            Andy
              • 26325
              • 36 Posts
              ajayre, can you post your complete htaccess code? At this point I’m not sure what you currently are using.
                Visit MODx.mobi to read these forums on mobile devices.
                • 727
                • 502 Posts
                Hi, it’s:

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


                Thanks! Andy
                  • 26325
                  • 36 Posts
                  Quote from: ajayre at Sep 06, 2006, 09:20 AM

                  Hi, it’s:

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


                  Thanks! Andy

                  I know you mentioned you tried adding rewritebase /, did you do it like this? Also add the slash in the last line "/index".
                  RewriteEngine On
                  RewriteBase /
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

                  Does this htaccess give the same log results as the one you posted?
                  IS MODx loaded in your root directory for the URI?
                  I tried your site but it is down, I’m guessing you were working on things.

                  ..Paul
                    Visit MODx.mobi to read these forums on mobile devices.
                    • 727
                    • 502 Posts
                    Hi Paul,

                    I tried that and it still fails eventually. I checked and my site is running. You can see it here: http://www.beverleyinpictures.co.uk.
                    I’m not sure it is the friendly URLs that is causing the problem - it seems like PHP calls the same function three times for some reason, and this only happens when friendly URLs are enabled.

                    Andy
                      • 26325
                      • 36 Posts
                      Quote from: ajayre at Sep 06, 2006, 10:25 AM

                      Hi Paul,

                      I tried that and it still fails eventually. I checked and my site is running. You can see it here: http://www.beverleyinpictures.co.uk.
                      I’m not sure it is the friendly URLs that is causing the problem - it seems like PHP calls the same function three times for some reason, and this only happens when friendly URLs are enabled.

                      Andy

                      Andy, I just clicked through some pages in your site and the FURL’s seemed to work fine. What problem are you currently having? Have you tried clearing the cache of your browser or tried using another browser or computer?
                        Visit MODx.mobi to read these forums on mobile devices.

                      This discussion is closed to further replies. Keep calm and carry on.