I created a fake page in wordpress, that i catch with this code:
if ($_GET['fake_page'] == "myfakepage") {
add_filter('the_title','plugin_myown_title');
add_filter('the_content','plugin_myown_content');
add_action('template_redirect', 'plugin_myown_template');
}
this works correctly.
Now what I’d like to do is to rewrite such this url
my_site?fake_page=myfakepage
in
my_site/product/myfakepage
where product is an existing page created from wordpress dashboard.
I followed this guide:
http://statichtml.com/2010/mod-rewrite-baseon-on-query-string.html
and defined this rule:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^fake_page=(.*)$ [NC]
RewriteRule ^/$ my_site/product/%1 [NC,L,R=301]
but what i get is
my_site/product?fake_page=myfakepage
where is the problem?
Besides I would like to know if typing into browser:
my_site/product/myfakepage
i could make wordpress treats it as
my_site?fake_page=myfakepage
without any redirect.
Thanks!
Try this code from your functions.php:
Note: you do not need that custom .htaccess. BTW: you souldn’t modify .htaccess directly, never. There is an extensive Rewrite API in WordPress which allows you to apply custom rules.