We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37044
    • 68 Posts
    Version 2.2.0
    Note - all tests on same server
    Note - I have spaced the h t t p in the below code as it was getting messed up on submission
    Standard friendly urls are set up and working fine

    So I have a fairly standard htaccess file as below:

    # Friendly URLs Part
    RewriteEngine On
    RewriteBase /
    #
    # Force all pages to go to www.domain.co.uk for SEO
    RewriteCond %{HTTP_HOST} !^www\.domain\.co.uk [NC]
    RewriteRule (.*) h t t p ://www.domain.co.uk/$1 [R=301,L]
    #
    RewriteRule ^agency/([1-9][0-9]*)/?$ index.php?q=agency&agency=$1 [NC,L]
    #
    # Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


    Three main parts

    • Standard modx re-write to force in www.
    • Bit I have added which re-writes in a an additional query string for a specific page IE domain.co.uk/specificpage/1 to domain.co.uk/?q=specificpage&page_content_id=1
    • Standard modx friendly urls re-write domain.co.uk/page to domain.co.uk/?q=page

    I have tested this out side my site with just a very basic PHP page that returns the contents of print_r($_GET) and all seems to work fine (see inaction here - http://tinyurl.com/cqyfg35) and it returns:
    Array
    (
        [q] => agency
        [agency] => 1
    )

    But when I add the htaccess to my Modx install the friendly urls work fine but the url for my page which requires the addition query string gets re-written to domain.co.uk/specificpage and it drops the additional /1.

    Im assuming this is due to something Modx is doing - anyone have any ideas how to fix this ?

    I really need to get this project live!

    Thanks. [ed. note: megasteve4 last edited this post 14 years, 4 months ago.]
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Can you try an upgrade to 2.2.2? I recall something related to custom friendly URLs being fixed in there, but not entirely sure when that bug made it into the core.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 37044
        • 68 Posts
        Mark = legend!
        Thanks for that tip - I have upgraded and my furls do work now with my custom query string.

        However there is one oddity which I would really like to fix...

        If I go to:
        http://www.domain.co.uk/agency/1

        I land on the agency page of my site and agency with id '1' is displayed.

        But once the re-write has happened the url in the address bar ends up as:

        http://www.domain.co.uk/agency/?agency=1

        So you can see despite furls working with my custom query string the 'aesthetic' end result still doesn't seem right...

        I really have no idea about how to go about fixing this - any suggestions?

        Once again thanks for your time.