I have a WordPress page that accepts a query string argument:
http://x.com/page-name/?parameter=value
This works fine. The page gets the value of $_GET[‘parameter’] correctly.
What I want to do is make it possible to type this as a normal URL:
I need the ability to rewrite the URL so the user enters URL 2, and WordPress gets URL 1. I am using Apache and would prefer to do this with mod_rewrite and .htaccess. Any advice?
You can do this within WP using your theme’s functions.php:
Re-save your permalink settings once after implementing.
page
is the slug of the page to point to when the user access this URL (domain.com/page/remove/432
), and$matches[1]
should be the number afterremove/
in the URL. This number is accessible by the variable specified later,$query_vars[] = 'removeid';
/ $removeid on the target page’s template will be the number in the URL, if specified.