Im not saying that this will solve it, but normally when you escape such characters you use a backslash \
Eg:
add_rewrite_rule('category1', 'shop?filters=marken\[20\]', 'top');
Hey,
thanks for your answer!
I’ve already tried that, but for some reason the whole method doesn’t work.
Now I’ve installed a plugin for mod rewrites, but it also doesn’t work with [] brackets.
Attempting to escape the brackets adds another backslash after saving the changes, really weird… so from shop?filters=marken\[20\] it turns into shop?filters=marken\\[20\\] and so on.
Is there anyone who experienced a problem like this?
Or any other solutions?
I NEED to rewrite the URLs because of SEO and WordPress doesn’t allow brackets in menue links. So I just can’t put the link like shop?filters=marken[20] into the menue, the brackets simply get replaced by wordpress.
I dont know what I was thinking when I posted that yesterday. Since its in a GET call you need to urlencode them.
add_rewrite_rule('category1', 'shop?filters='.urlencode('marken[20]'), 'top');
Or hardcode it to:
%5B20%5D
[ = %5B
] = %5D
You can use the following site http://www.url-encode-decode.com/
Edit:
You do this in an init action right? And have you saved the permalinksettings again?
Hey,
maybe there’s something wrong with my wordpress setup at all…
I added the following code to my functions.php:
function cool_rewrite()
{
add_rewrite_rule('c1', 'shop?filters='.urlencode('marken[20]'), 'top');
}
add_action('init', 'cool_rewrite');
Now nothing happens, I simply get the 404 page opening /c1 .
With the rewrite plugin I tried to rewrite the cat1 page with the shop page, that DOES work! At least one thing working.. 🙂
http://prntscr.com/7afeb2
But if I try to rewrite the license.txt (just for testing), I simply get the start page.
http://prntscr.com/7aff21
Is there anything wrong in the specific htaccess syntax or something?