0

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" />
</form>

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.

Thanks.

4
  • so you mean to not refresh page but send the form data ? why don't you use ajax to handle it.
    – Amit Kosti
    Commented Aug 1, 2012 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
    Commented Aug 1, 2012 at 13:33
  • do you want to keep the url /do-this/ but with the content of index.php ?
    – Amit Kosti
    Commented Aug 1, 2012 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
    Commented Aug 1, 2012 at 14:36

1 Answer 1

-1

a colleague fixed it using parse_request.

similar to this one:

http://willnorris.com/2009/06/wordpress-plugin-pet-peeve-2-direct-calls-to-plugin-files

1
  • this is not a valid answer, please add more information that actually show how you solved the problem.
    – Aurovrata
    Commented Jul 27, 2020 at 5:57

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.