We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27437
    • 49 Posts
    wondering if some1 ever made a script for this situation:

    - I build a new website for a client, now client wants to have old links turned into symlinks, so far so good
    - his old links vary with .html suffix or none, so I removed the suffix in the new website
    - now the new links might have been indexed already so i can do 2 things afaik
    - manually write .html in the aliases of the new site
    - or write a script that when it encounters a resource without the .html suffix and tends to redirect a 404 to look for a resource with an alias that has the .html suffix
    • If your resources all have aliases to match the old site, you could either use a rewrite rule in your .htaccess file, or use a plugin with the OnPageNotFound event to load the page with the same alias.

      The server passes the page requested to MODX as "q=alias.suffix", so all the plugin would need to do is to extract the alias and use that to load the correct resource.
        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
      • That or create a second HTML Content Type with the extension and assign that to the SymLink Resources to cover the old Resources with a different extension. Of course, redirecting (301) all .html -> no extension maybe be better in the long run.
          • 3749
          • 24,544 Posts
          You probably know this, but for others, all links on the site should be in the form of link tags:

          [[~12]]


          Where the number is the ID of a resource. A full link would look like this:

          <a href="[[~12]]">Page 12</a>


          Once you've done that, all links on the site will work regardless of the page alias or extension.

          For your SEO issue, depending on the nature of the site and the number of pages, I would be tempted to just make the home page the error page and install the LogPageNotFound extra, which will capture all attempts to visit the bad links. Then I'd use the log to create 301 rewrite rules in .htaccess for all the old links.

          That way you don't need to mess with Symlinks, a plugin, or some universal rewrite rules that might have unintended consequences.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
          • Doesn't the Redirector plugin do exactly that Bob?
              Frogabog- MODX Websites in Portland Oregon
              "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
              Having server issues? These guys have MODX Hosting perfected - SkyToaster
              • 3749
              • 24,544 Posts
              I'm not sure I've never used it.

              BTW, I think the MODX team has extended my LogPageNotFound plugin to let you automatically update the .htaccess file with rewrite rules, but I don't know if it's been released as an Extra. If not, I'll probably do it someday.



              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
              • I just set it up a few weeks ago on a site that was static with the .htm extension. I had to enter every possible page/file from the old site but fortunately there were only four pages in the first place. It seems to work rather well.
                  Frogabog- MODX Websites in Portland Oregon
                  "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                  Having server issues? These guys have MODX Hosting perfected - SkyToaster