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

    We are using ModX a long time now to support all our brokers with a raly good CMS for their website. For example: http://www.uwjachtmakelaar.nl/. The way we did this was creating a snippet and an addition to the .htacces file to redirect the detail pages to a single modx page.

    Now we are going to implement ModX on our own website as well (http://www.yachtfocus.com). We are planning to use the same method but are wondering if anyone has a better idea. The problem I face has to do with the friendly url part. Since we are rewriting some results it is still possible to use the same url in modx. There is no check. Since the pages of the dynamic content are constantley changing we cannot freeze a single page name or so.

    Is there a way to block a directory from being used by the modx friendly url system. For example http://www.yachtfocus.com/boats/.....

    I love to hear from anyone.

    Mattijs
      • 16278
      • 928 Posts
      I think you can achieve this just by being careful about the order of rewrite commands in .htaccess, and using [L] on your custom rules to make them "last". I don’t like putting query strings on pages that get into search engines (they seem to act as a magnet for hackers and site-hoovers), so pictures in my photo gallery have URLs such as "http:/example.com/pix/N123456", where N123456 is the ID of the photo in the database. The rewrite rules below turn this into a query string for the picture page galleryshow.html, so that URL becomes "http:/example.com/galleryshow.html?id=N123456"
      Options +FollowSymlinks
      RewriteEngine On
      RewriteBase /
      
      # for gallery pictures without query in URL
      RewriteRule ^pix/(\w*)/?$ galleryshow.html?id=$1 [L]
      
      # Exclude /assets and /manager directories and images from rewrite rules
      RewriteRule ^(manager|assets)/*$ - [L]
      RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
      
      # For Friendly URLs
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]