Here is my rewrite rule code:
add_rewrite_rule('tides/([^/]+)/([^/]*)', 'index.php?page_id=4348&location=$matches[1]&month=$matches[2]', 'top');
add_rewrite_tag('%location%', '([^&]+)');
add_rewrite_tag('%month%', '([^&]*)');
This works great for the following URL:
/tides/mylocation/mymonth/
but 404's on the following:
/tides/mylocation/
I'm flushing the rewrite rules every time I change the code. I tried changing *
to +
but no help there.
Any ideas?
Edit:
Some answers were suggesting adding another rewrite rule so I added:
add_rewrite_rule('tides/([^/]+)/$', 'index.php?page_id=4348&location=$matches[1]', 'top');
before my other rule, but still no luck.