Clean URL in a Multi Tenanted Environment using mod rewrite

  1. 12 years ago

    Hi

    I have successfully set up fop2 and have got it working in a multi tenanted environment but would like it to work with clean URLs

    each on e of our contexts will be 4 alpha characters so I have this in my virtual host config

    RewriteEngine On
    RewriteRule ^([a-z]{4})$ /?context=$1

    And have tried a lot of permutations of the above.

    I know that mod rewrite is enables because if I put /abc at the end of the user I get an apache error whereas if I put /abcd I get a fop2 login but it's like it ignores the context aspect.

    Does anyone have any ideas about this?

  2. admin

    8 Nov 2012 Administrator

    Not sure exactly what your problem might be, I am not an expert with mod_rewrite. I would try to setup some debugging for it to get an idea on what is happening, perhaps this article might help:

    http://www.latenightpc.com/blog/archive ... od_rewrite

  3. Hi

    Thanks for the tip, it really helped.

    So, the working condition I've got to is:

    RewriteRule ^/([a-z]{4})$ ?context=$1 [L,R]

    The key bit here is the R flag which issues a redirect to the browser and we end up at the messy URL again, which has got me wondering; where exactly is the get variable being picked up? Is it being pulled by php or extracted from the URL string by the javascript?

  4. admin

    8 Nov 2012 Administrator

    The variable is picked up from the GET request (it can also be picked up from javascript title attribute). But in your case the get is all that matters. If mod_rewrite is redirecting you and passes the request with the context in it, then it should work just fine. But as I am really not familiar with mod_rewrite and its complexities, I cannot tell you if something is amiss. Not sure if you need to pass /fop2/?context= instead of just context= for example.

or Sign Up to reply!