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

    I started using MODx Revolution with Beta 5 and really love its many improvements, especially the much streamlined work flow. Right now I only have the following little issue with friendly URLs.

    When setting a link via a Wayfinder call or <a href="[[~id]]">link text</a>, Apache gives out an error message, except for the home page.

    Here is my document tree setup and the error messages I receive:

    Files and Folders:
    + Home (id 1), alias: home
    + Products (id 2, document folder), alias: products
    ++ Category 1 (id 3, child document of "products" folder), alias: category-1
    + Contact Us (id 6), alias: contact

    Output:
    Home: http://localhost/modx_rev/
    Alias is not displayed, but page opens without an error message

    Products: http://localhost/modx_rev/products/
    Not Found
    The requested URL /modx_rev/products/ was not found on this server.

    Category 1: http://localhost/modx_rev/category-1.html
    Not Found
    The requested URL /modx_rev/category-1.html was not found on this server.

    Contact Us: http://localhost/modx_rev/contact.html
    Not Found
    The requested URL /modx_rev/contact.html was not found on this server.

    -------------------------------------------------------------------

    The following are my MODx Revolution system settings and server configuration with regard to friendly URLs:

    System-->System Settings-->Friendly URL:
    Automatically generate alias: 0
    Use friendly Alias Path: No
    Use friendly URLs: Yes
    Use friendly aliases: Yes
    container_suffix: /

    Directory structure:
    /var/www/modx_rev

    .htaccess file in modx_rev folder:
    RewriteEngine On
    RewriteBase /modx_rev

    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]

    .htaccess file in manager folder:
    RewriteEngine On

    -------------------------------------------------------------------

    I tried fiddling with these settings but haven’t been able to make MODx create usable links. Therefore I hope someone could point me to a possible solution.

    Best regards,

    Stefan

      • 17499 ☆ A M B ☆
      • 872 Posts
      Hello Bytesource,

      Try to scitch from :

      RewriteBase /modx_rev

      to :

      RewriteBase /

      in your root .htaccess file
        • 4414
        • 63 Posts
        Hello lossendae,

        I tried as you suggested and changed RewriteBase /modx_rev to RewriteBase /

        I then restarted Apache, logged off the MODx manager, logged in again, cleared the cache and tested the links again. Unfortunately I still get the exact same error messages.

        Hopefully this test result can lead us to the solution of my link problem smiley

          • 22303 MODX Staff
          • 10,725 Posts
          It should be:
          RewriteBase /modx_rev/

          or you can leave out RewriteBase altogether and use a slightly altered RewriteRule:
          # The Friendly URLs part
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ /modx_rev/index.php?q=$1 [L,QSA,NC]
          
            • 4414
            • 63 Posts
            Hi OpenGeek,

            I tried both of your suggestions but still get the exact same error message.

            1)
            RewriteEngine On
            RewriteBase /modx_rev/
            
            # The Friendly URLs part
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]

            2)
            RewriteEngine On
            
            # The Friendly URLs part
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /modx_rev/index.php?q=$1 [L,QSA,NC]


            I would like to point out that friendly URLs seem to be working, at least the output (e.g. /contact.html) is correct. It’s just that for some reason Apache cannot find these pages and therefore throws an "Not Found" error.

            I still think this is caused by some wrong setup and not by MODx itself. Is there a way to test this? I really want to move over to MODx Revolution but for this I need functional page links wink

            Best regards,

            Stefan
              • 4414
              • 63 Posts
              In case you want to take a look at it, here is the output of my server’s phpinfo(): http://docs.google.com/View?id=dgcw4nps_361gdzzdgc6

              Edit: Could it be that I have to modify httpd.conf in some way? Right now this file is empty.
                • 2364
                • 73 Posts
                Sounds like a mod_rewrite is not enabled.
                For linux machines run under the root:
                a2enmod rewrite
                service apache2 reload
                or
                /etc/init.d/apache2 reload


                P.S. httpd.conf on Debian based systems is obsolete (using apache2.conf), but Unix and post-RedHat distros uses httpd.conf
                  • 4414
                  • 63 Posts
                  I have finally been able to solve the my problem:

                  First of all I checked /etc/apache2/mods-enabled to make sure mod_rewrite was enabled. There was rewrite.load which is a symlink to the actual rewrite module.

                  After that I followed this test only to find out that Apache ignored my .htaccess files:
                  http://blog.coldtobi.de/1_coldtobis_blog/archive/219_how_to_check_if_you_have_modrewrite.html

                  Then I opened /etc/apache2/sites-available/default and realized that AllowOverride was set to None. After changing AllowOverride to All in <Directory /> as well as <Directory /var/www/> and restarting Apache (sudo /etc/init.d/apache2 restart
                  ) all links worked!

                  DocumentRoot /var/www
                  	<Directory />
                  		Options FollowSymLinks
                  		AllowOverride All
                  	</Directory>
                  	<Directory /var/www/>
                  		Options Indexes FollowSymLinks MultiViews
                  		AllowOverride All
                  		Order allow,deny
                  		allow from all
                  	</Directory>


                  The only thing I had to change in my .htaccess file was the RewriteBase, which I changed from /modx_rev to /modx_rev/ just as OpenGeeK suggested.

                  Thanks again for your help!

                  Best regards,

                  Stefan
                    • 6437
                    • 157 Posts
                    Thanks for the update Stefan - this resolved the issue for me also.

                    Cheers,

                    DM
                      • 32699 ☆ A M B ☆
                      • 427 Posts
                      I made a special note in the friendly urls concerning the need for the rewritebase to end in a /

                      http://svn.modxcms.com/docs/display/revolution/Using+Friendly+URLs
                        Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

                        Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com