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

    I have just set friendly urls for a website which is stored alongside other websites in the htdocs folder. Each folder name in htdocs corresponds to a domain name.The website can be directly accessed with its own domain name. So, "www.somewebsite.com" means "htdocs/somewebsite.com". Each domain-folder has its own ".htaccess" file.

    Here, the code from the .htaccess file. Please ignore the anchor html tag as it was improperly added by the pluggin that is used to display the code.
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    #AllowOverride all
    
    # Force www.somewebsite.com instead of just somewebsite.com
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.somewebsite\.com [NC]
    RewriteRule (.*) http://www.somewebsite.com/$1 [R=301,L]
    
    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


    Now, the friendly URL redirection is working, but the document id is still displaying in the address bar. For instance if the FURL alias for document # 123 is "hello-world", then "http://www.somewebsite.com/hello-world" redirects to "http://www.somewebsite.com/123".

    In "Tools, Configuration, Friendly URLs", setting the "Access path for simple alias" to TRUE gave me some better result: "http://www.somewebsite.com/hello-world/123".

    But of course, I would like to get rid of the document id in the URL that is displayed.
    Also, if possible, I would also like to keep the "Access path for simple alias" to FALSE, as I want to keep URLs short.

    Maybe the problem comes from some folder offset when the website is not directly installed in htdocs, but how to solve it? Some MODX file to edit or RewriteRule to adapt?

    I tried adapting RewriteBase from / to the domain folder and this gives an internal server error.
    So, I assume that the RewriteBase is correctly set.

    Thanks a lot for your help. [ed. note: Jul last edited this post 11 years, 7 months ago.]
    • Do the resources have "alias" values set? You can also configure MODx to use the pagetitle as the alias; it will convert it to lower case and replace spaces with hyphens.
        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
        • 15001
        • 697 Posts
        Susan, your question helped me sooo much!

        The document that I was using for my tests had a alias. But I had completely forgotten it contained a call to the [[FirstChildRedirect]] snippet. And of course the first child had no alias set !

        Everything works fine now. Thanks a lot !