I need to use javascript redirection in one of my scripts. With /%postname%/
WP permalinks structure redirection works like it should but with default it always redirects to home page.
/%postname%/
structure script:
window.location.replace(encodeURIComponent("http://www.url.com/customposttype/postslug"));
default permalinks structure script:
window.location.replace(encodeURIComponent("http://www.url.com/?customposttype=postslug"))
The issue is that your script is doing a replace, but really what you want is to set the window location:
Change your redirects from:
to
And it should work properly.