Saturday, 15 May 2010

string - Rewrite rule help should be simple but not for a newbie like me -



string - Rewrite rule help should be simple but not for a newbie like me -

my oroginal url looks this

http://www.example.com/showads.php?type=1

and rewrite seems work

rewriterule ^listings/type/([0-9]+)/?$ showads.php?adtype=$1 [nc,l]

so have type www.example.com/listings/type/1 , goes original url

my problems comes when add together 1 more parameter original url this

http://www.example.com/showads.php?type=1&clearfilters

i have tried several combinations of rewrites none of them work.

the lastly 1 have before giving this

rewriterule ^listings/type/([0-9]+)/clear?$ showads.php?type=$1&clearfilters [nc,l]

what doing wrong? in lastly rewrite? help appreciated.

thanks

jt

better explanation

thanks reply. however,that still not work.

let me seek explain happens

if type url

http://www.example.com/showads.php?adtype=3&clearfilters

i expected results. , here explanation of it's use

a user clicks on various links on site , each link sets different session variable. on span of few clicks there 5 or 6 session variables set.

if 1 submit url without clearfilters

http://www.example.com/showads.php?adtype=3

you setting session variable adtype 3

so have adtype session variable , perchance few other set

when submit url clearfilters set

http://www.example.com/showads.php?adtype=3&clearfilters

the page unsets existing session variables , sets adtype session 3.

having said that, looking rule clean url , type like:

http://www.example.com/listings/type/3/clear

to same ugly url.

maybe there improve way. ears.

thanks

jt

it not clear question if want same replacement url regardless of whether have or not have /clear part of url.

if want same replacement url or without /clear, can utilize this:

rewriteengine on rewriterule ^listings/type/([0-9]+)(/clear)?$ showads.php?type=$1&clearfilters [nc,l]

if want clearfilters parameter in replacement url when typed url has /clear part, can this:

rewriteengine on rewriterule ^listings/type/([0-9]+)$ showads.php?type=$1 [nc,l] rewriterule ^listings/type/([0-9]+)/clear$ showads.php?type=$1&clearfilters [nc,l]

string apache rewrite rules

No comments:

Post a Comment