You  might have faced error where .htaccess wont recognize the backtrack variable after $9 such that if you specify “$10″ then it will return you “0″ as value to that key in URL param. The mod_rewrite module is confused which varible to return $1 or $o. Lets see the problem first,

Problem :

RewriteRule ^tools/chart(/id_([^\/]+))?(/user_([A-Za-z0-9_]+))?(/action_([A-Za-z0-9_]+))?(/date_([A-Za-z0-9_]+))?(/service_([A-Za-z0-9_]+))?(/.+)$ my_php_file.php?id=$2&user=$4&action=$6&date=$8&service=$10&message=$12


Apache’s official website says:
Back-references are identifiers of the form $N (N=0..9), which will be replaced by the contents of the Nth group of the matched Pattern.
In the above RewriteRule, the variables $10 and $11 will return 0 and 1 as values respectively. Now let us look at the workaround to this probelm.

Solution :

RewriteCond %{REQUEST_URI} /(service_([A-Za-z0-9_]+))?(/.+)$
RewriteRule ^tools/chart(/id_([^\/]+))?(/user_([A-Za-z0-9_]+))?(/action_([A-Za-z0-9_]+))?(/date_([A-Za-z0-9_]+))?(/service_([A-Za-z0-9_]+))?(/.+)$ my_php_file.php?id=$2&user=$4&action=$6&date=$8&service=%2&message=%3

Using the above RewriteCond and RewriteRule we can grab the values of the group after 9.

Hope this helps icon smile Advanced htaccess for more than 10 group of backtrack references

Cheers!!
Realin !

Delivered by FeedBurner

Share this Post