php - trouble with getting my mod_rewrite rules to run -
i have been trying several variations server redirect - seem fail. :(
this url:
"meaty-monster-bikes.zz-reviews.com/monster-bikes/p1c9.html"
now data want collect in variables portion after
"meaty-monster-bikes.zz-reviews.com/"
so in case want "monster-bikes" , "p1c9"
then using collected variables server can redirect to:
"zz-reviews.com/index.php?p=1&c=9&k=monster-bikes"
i have thried in .htaccess file:
options +symlinksifownermatch rewriteengine on rewriterule ^[\.0-9-a-z]+/([-a-z]+)/p([0-9]+)pg([0-9]+)\.html$ index.php?p=$2&c=$3&k=$1 [nc,qsa,l]
i tried :
rewritecond %{http_host} ^[.+].zz-reviews.com/([-a-z]+)/[.+]$ [nc] rewriterule ^[\.0-9,:\/-a-z]+p([0-9]+)c([0-9]+)\.html$ index.php?p=$1&c=$2&k=%1 [nc,qsa,l]
as far can see, both should work, neither do.
this webpage:
http://zz-reviews.com/index.php?p=1&c=9&k=monster-bikes
if click on category "monster bikes"
you see url:
"http://meaty-monster-bikes.zz-reviews.com/monster-bikes/p1c9.html"
the htaccess not redirect.
can see mistake ?
thanks .
.
rewriterule ^([^./]+)/([a-z]+)(\d+)([a-z]+)(\d+)\.html$ index.php?$2=$3&$4=$5&k=$1 [l,nc]
this rule need - when go url
meaty-monster-bikes.zz-reviews.com/monster-bikes/p1c9.html
you redirect (behind scenes) url
meaty-monster-bikes.zz-reviews.com/index.php?p=1&c=9&k=monster-bikes
explaination:
^([^./]+)
- starts after com first arg ($1
) take characters until /
- take string "monster-bikes"
/
- / character of url
([a-z]+)
- follow abc letter (you can change if there other strict) take "p" ($2
)
(\d+)
- follow number - take "1" ($3
)
([a-z]+)
- follow abc letter - take "c" ($4
)
(\d+)
- follow number - take "9" ($5
)
\.html$
- ends string ".html"
redirect index.php assembled parameters:
index.php?$2=$3&$4=$5&k=$1
= index.php?p=1&c=9&k=monster-bikes
Comments
Post a Comment