0

I've got url-rewriting partially working. I have this rule:

add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?p=27&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]','top');

When I request a page like this:

http://yourpage.com/wp/somepage/florida/02-03-2012/03-03-2012/

The Visitor gets redirected to:

http://yourpage.com/wp/somepage/

But I'd like to keep the additional parameters of the original url. How can I achieve this?

And I noticed something else. When I generate a link like above from a form via JavaScript I get "page not found" although the url is correct. Now when I refresh that same page I get redirected to the page mentioned above. Why isn't it working on the first try?

I'd appreciate any help.

Kind regards, Denyo

1 Answer 1

2

Okay I figured it out. Instead of using this rewrite rule:

add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?p=27&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]','top');

I now use this one:

add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?pagename=somepage&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]','top');

And now everything works like I wanted it to. Obviously using the page id instead of the page name was the problem.

1
  • Thank you so much, I had this problem for a month and could not find the answer ! Commented Feb 7, 2018 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.