on the root page of a WordPress site we have a custom page template, that also handles some forms and dynamically changes part of the content.

Something like this:

<form action="" method="post">
<input type="hidden" name="action" id="action" value="do_this" />

and then in the page template we check for $_POST['action']=="do_this". Works perfectly.

Now we would like that when these forms are posted to have the url change (action="/do_this").

For that to work, we need /do_this to deliver the root page, but the url to not change.

we have tried this in .htaccess

RewriteRule ^do_this(.*)$ index.php?p=12 [L]

but it changes the browser url.

It must have something with WordPress, since if we use another file

RewriteRule ^do_this(.*)$ test.html [L]

it works: the url is not changed and the test.html is being delivered.


  • so you mean to not refresh page but send the form data ? why don't you use ajax to handle it. – amit Aug 1 '12 at 10:48
  • @amit: the page will refresh, the data it will be normally posted, but the new url should be mapped only internally to the same page – memical Aug 1 '12 at 13:33
  • do you want to keep the url /do-this/ but with the content of index.php ? – amit Aug 1 '12 at 13:45
  • yes :) true. basically to have the do-this url deliver the content of the root page, but i keep getting 404 errors from WP or apache does a redirect. this all works for another file, not index.php. – memical Aug 1 '12 at 14:36

a colleague fixed it using parse_request.

similar to this one:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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