So after a lot of troubles (and thanks to this answer) I managed to make a GET parameter look better in URL, from
www.url.com/mypage/?id=123
to www.url.com/mypage/123/
I hoped that would solve the redirection problem with Facebook sharer, but it doesn't.
Facebook still recognizes my shared url as www.url.com/mypage/
How is it even possible? Studying some Wordpress rewrite rules, I learned that when I type (link1) www.url.com/nameofpage/
in fact I get redirected to (link2) www.url.com/?pagename=nameofpage
.
So why when I share link1 it recognizes it without redirecting to link2? How can I share the link I want (with id parameter) and make it work without redirections?
Edit: my code to rewrite the URL
add_action( 'init', 'miareg' );
function miareg(){
add_rewrite_tag("%id%", '(\d+)');
add_rewrite_rule('^flipbook/([^/]*)/?','index.php?page_id=6031&id=$matches[1]','top');
}
The real name of the page I have to share is /flipbook/ and the parameter is "id"; for example I have to share www.mywebsite.com/flipbook/?id=82
.
To explain page_id=6031
: it's of course the id of the page (has nothing to do with the id mentioned before - the parameter)
www.url.com/nameofpage/
is not redirect to link2www.url.com/?pagename=nameofpage
. What is happening is a rewrite, that is quite different of a redirect. The rewrite is a process within you server and no one can see it. Can you post the exact code are you using?