We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10702
    • 107 Posts
    Does anybody know how to change "-" into "_" between the words of the file-name using the function "Use friendly Aliases"?

    Or how can I configure MODx-Revolution to accept "_"? Unfortunately my MODx Revolution-installation always changes "_" into "-"...

    Gerdi
      • 10702
      • 107 Posts
      Can I change this by changing a core-file or is it possible to change it somewhere in the setting-area?
        • 24935
        • 160 Posts
        It is right here...

        System > System Settings
        Area: Friendly URL
        friendly_alias_word_delimiter
          • 10702
          • 107 Posts
          Great. Thanks a lot. Do you also know if it is possible to use "_" and "-" for this purpose in the same setting? For example be able to have a file file-a.html and file_b.html on my website?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            As a general rule, _ is frowned upon in URLs, as it is hidden if the <a> tag has the default text-decoration of "underline".
              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
              • 10702
              • 107 Posts
              Quote from: sottwell at Sep 20, 2010, 12:15 AM

              As a general rule, _ is frowned upon in URLs, as it is hidden if the <a> tag has the default text-decoration of "underline".

              Hi sottwell,
              you are right. The problem in my cases is that I have to import a website into MODx revolution. The former website has many, many "_" in the URLs. To ease the import and not being forced to correct every link I was going to let "_" in the old pages.

              For new pages I would like to use "-"

              Therefore I would be great if I can use "-" as well as "_"

              Do you think this is possible somehow?

              Thanks a lot in advance!
              Gerdi
                • 10702
                • 107 Posts
                So it seems like there is no chance to us "-" as well as "_" in the same setting for friendly URLs or friendly Aliases?

                Or can I maybe make changes in the core to realize this?

                Or can I put a code-snippet to the .htaccess-file to convert all incoming requests changing "_" to "-"? Does anybody know this?
                  • 22019
                  • 390 Posts
                  Copied and pasted from http://forums.digitalpoint.com/showthread.php?t=278494 (not my answer). In this instance, the request was to change ’+’ into ’_"

                  "You can do this in mod_rewrite but it’s not ideal. Unfortunately there is no such command to replace a certain character with another and therefore you’d need to create regex patterns for every number of + there may be in the URL. If you’re only ever expecting one +, you can use:
                  RewriteRule ^tag/(.+)\+(.+)$ tag/$1_$2 [R=301]

                  If there may be two +, you’d need another rewrite rule to match that as well:
                  RewriteRule ^tag/(.+)\+(.+)\+(.+)$ tag/$1_$2_$3 [R=301,L]

                  And so on. As I’m sure you can imagine, PHP would quickly become a better solution:
                  php Code:

                  if ( strpos($_SERVER[’REQUEST_URI’],’+’) ) {
                  header(’Location: http://www.domain.com’ . str_replace(’+’,’_’,$_SERVER[’REQUEST_URI’]);
                  exit;
                  }

                  "

                  Not entirely sure where you’d do the PHP method, but the htaccess one should work.
                    Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
                    • 10702
                    • 107 Posts
                    Hi odeclas,

                    thank you very much for your help.

                    Do you also know how we can pass urls like this:

                    http://www.domainxyz7890.com/file_para_article.php?articles_ID=370
                    http://www.domainxyz7890.com/file_para_article.php?articles_ID=371


                    automatically into

                    http://www.domainxyz7890.com/file_para.php?articles_ID=370
                    http://www.domainxyz7890.com/file_para.php?articles_ID=371


                    Is this possible by .htaccess?

                    Gerdi