apache - Mod rewrite, append directory as parameter -
i'm wondering how directory rewriting directory gets appended parameter regardless of remaining url.
for example, if have urls these:
example.com/peter/lois/stewie.php example.com/peter/lois/brian.php?drinks=martinis example.com/peter/lois/quagmire/meg.php
and need them rewrite to
example.com/lois/stewie.php?person=peter example.com/lois/brian.php?drinks=martinis&person=peter example.com/lois/quagmire/meg.php?person=peter
how go doing that?
thanks!
edit
so have implemented in sites-available file:
rewriterule ^/([a-z0-9]+)/lois(.*) /lois$2?person=$1 [qsa,l]
but instead of returning like
example.com/lois/stewie.php?person=peter
it's returning like
example.com/peter/lois/stewie.php?person=peter
so it's putting parameter @ end of url should, it's not dropping earlier directory.
mod_rewrite work this:
rewriteengine on rewriterule ^([a-z0-9]+)/(.*\.php) /$2?person=$1 [qsa,l]
Comments
Post a Comment