We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11858
    • 130 Posts
    I’m trying to redirect a URL:

    www.example.com/content.aspx?ID=2&ParentID=60&MicrositeID=0&Page=1


    to

    www.example.com/products


    My rewriteCond looks like this (I’m using MODx as a CMS)

    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    
    Redirect 301 /content.aspx?ID=60&ParentID=0&MicrositeID=0&Page=1 http://www.example.co.uk/products
    
    


    Does anyone have any idea how specify a rewrite rule for a url with so many question marks, ampersands and parameters in it? I probably need to do rewrite rules for everything, not just simple redirects?
      • 17553
      • 2 Posts
      You can try the following:
      RewriteRule ^content.aspx?ID=2&ParentID=60&MicrositeID=0&Page=1 /products [R=301,L]

      Friendly URLs part
      # The Friendly URLs part
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

        Computer Science Graduate and Facebook Application Developer
        • 36575
        • 104 Posts
        I used the spreadsheet here: http://www.mbstrategic.com/02/301-redirects-for-dynamic-urls-to-static-pages-with-htaccess/

        Your code would be:
        RewriteCond %{QUERY_STRING} ^ID=2&ParentID=60&MicrositeID=0&Page=1$
        RewriteRule ^content.aspx$ www.example.com/products? [R=301,L]