regex - .htaccess Manipulating the Query String -
as per wiki - https://wiki.apache.org/httpd/rewritepathinfo - shows how change url path query string:
rewriteengine on rewriterule ^/blah/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/? \ /blah.php?arg1=$1&arg2=$2&arg3=$3&arg4=$4 [pt]
this method requires predict exact amount, if there 5 levels 5 values:
/blah/1/2/3/4/5/
translating
blah.php?var1=1&var2=2&var3=3&var4=4&var5=5
is there way without pre knowing number of variables, being dynamic?
for example, 1 day user might enter 7, day 1, day 9 , rewrite regex being able handle them all?
to make dynamic should not bother breaking path info multiple query parameters. pass after blah/
php file , let php split on /
. can use rule:
options -multiviews rewriteengine on rewriterule ^/?(blah)/(.+)$ $1.php?path=$2 [l,qsa,nc]
Comments
Post a Comment