Trying to match and URL like this
linktosite/alphaNum/123/321/alphanum[alphanum].jpg
in .htaccess I can match and extract all the groups properly with
linktosite/(.+)/([0-9]+)/([0-9]+)/(.+)\[(.+)\]\.(.+)$
in add_rewrite_rule I can not make it match. I’ve tried escaping the [
with \[
, \\[
, \\\\[
and nothing works. I’ve also tried Q[E
and using it as x5b
91
and nothing works.
Also tried ([^\[]+)
to match non [
characters up to the [
What’s the proper way to match metacharacters like this?? Does the same for literal ()
I’ve found this to be one of the more poorly documented features of WordPress, so hopefully this is on track or will be corrected by someone more fluent in WP_Rewrite.
The basic gist is thus:
init
, useadd_rewrite_tag()
for any custom query string parameters that are in the rule. For a destination ofindex.php?this_is_custom=$matches[1]
, you must add thethis_is_custom
tag.Your example is a little light on code, particularly in the URL you’re trying to match (what do all those parameters correspond to?), so my answer is somewhat generic.