regex - RewriteRule to convert /a/b into ?x=a&y=b? -
this current rewrite rule, lets me pass url domain.com/pagename , evaluate domain.com/index.php?page=pagename:
<ifmodule mod_rewrite.c> rewriteengine on #create friendly url rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/?$ /index.php?page=$1 [l,qsa] </ifmodule>
what need do/add in there allow take url this:
domain.com/pagename/type/value
and evaluate this:
domain.com/index.php?page=pagename&t=type&v=value
(where both /type , /value optional)
??
thanks!
you can do:
<ifmodule mod_rewrite.c> rewriteengine on #create friendly url rewriterule ^index\.php$ - [l] # if request valid file - or rewritecond %{request_filename} -f [or] # if request valid directory rewritecond %{request_filename} -d # nothing ignore rules below rule rewriterule ^ - [l] # 1 parameter rule numbers rewriterule ^(\d+)/?$ index.php?page=$1 [l,qsa] # 1 parameter rule rewriterule ^([^/]+)/?$ index.php?page=$1 [l,qsa] # 2 parameter rule rewriterule ^([^/]+)/([^/]+)/?$ index.php?page=$1&t=$2 [l,qsa] # 3 parameter rule rewriterule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?page=$1&t=$2&v=$3 [l,qsa] </ifmodule>
Comments
Post a Comment