0

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)

  • You are missunderstanding, link1 www.url.com/nameofpage/ is not redirect to link2 www.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? – cybmeta Sep 11 '13 at 12:38
  • @cybnet You are right, my mistake. I added the code, can you please check if it's correct? Thank you – topoftheforts Sep 11 '13 at 15:18
0

I can see that you are rewritting to a specific page and I think that your problem is that Wordpress inserts the canonial meta tag in the <head> of the HTML automatically for all core post types (post, pages, ...). This meta tag will be pointing to the original page, because you are really in the page 'flipbook'. Maybe facebook is taking the information from the canonial meta tag as Google and the other big search engine will do.

Can you check the canonical meta tag of your pages?

  • Yes!!! Just figured it out a minute before you posted it :) It was the tag <meta property="og:url"> that pointed to the original page (I have SEO Yoast installed). – topoftheforts Sep 11 '13 at 15:57

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.