Pass request, Insert sub-domain, translate slashes

Discussion in 'Apache' started by venustech, Dec 7, 2011.

  1. #1
    I want to pass 404s to a PHP script. A logical example:


    URL: www.billybob.com/dkfjghsdklfhd/dsfsoghst.doc

    Translates to: www.billybob.com/shortcuts/dkfjghsdklfhd-dsfsoghst.doc



    The rules

    • Everything to the left of the first / is preserved i.e. the domain name
    • All / to the right of the first / are substituted with -
    • shortcuts/ is inserted after the first /

    My Idea

    Because there are already some rewrite rules and conditions, my idea is to use the ErrorDocument directive to pass 404s. Is this possible? If not, is there another solution? What's the Regex syntax?
     
    venustech, Dec 7, 2011 IP