Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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