We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8192
    • 4 Posts
    Hello dear community,

    I’m facing a new problem trying to set up friendly URLs on modx revolution 2.0.8-pl. I chose to use aliases, which are working very great.

    I’m trying to add a prefix to the files path and this options is not avaible on the systems settings.

    To make it clear, the original path is :

    www.mysite.com/index.php?id=2
    becomes www.mysite.com/2.html with friendly URLs
    and it would be perfect to become www.mysite.com/pages/2.html

    Aka simulating the presence of a folder at the root of the server.

    Did you ever wanted to do the same ? If yes, would you share a how-to ? smiley

    Thanks a lot,

    Duk3.


      • 34123
      • 103 Posts
      Hi,

      you could find an answer to your question in this forum. I am using this technic for my pagination.

      I ’ll post a link here ASAP.

      Here is an extract of my .htaccess file

      RewriteCond %{REQUEST_URI} /page/(.+?) [NC]
      RewriteRule (.*) /?page=%1 [L,QSA,NC]


      You have to rewrite a plugin GetPageFURL (here is mine)

      if ($modx->event->name == 'OnWebPagePrerender') {
      $output = $modx->resource->_output;
      $output = preg_replace('%/(.+?)/\\?page=(.+?)%mis', '/$1/page/$2', $output);
      $output = preg_replace('%/(.+?)/page/1%mis','/$1/', $output);
      $modx->resource->_output = $output;
      


      This code is an extract from my DB dump, i’ll have to remove the escaped characters (there must be some errors huh)

      You can easily adapt this code to your needs

      Edit : here is the correct link : http://modxcms.com/forums/index.php/topic,52296.0.html

      Regards
        Configuration Apache + Modx + MSSQL 2008
        ===============================
        Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.8
        OS : Windows 2008 R2
        SGBDR : Microsoft SQL Server 2008 (express)