The sites url structure is as follows:


I would like only one certain page on the site to resolve as:


This is so that when I run the link through the Facebook Sharing debugger at:


... the link works correctly. Currently, Facebook appears to strip query string parameters on pages shared that do not resolve as .html.

migrated from stackoverflow.com Oct 27 '16 at 12:44

This question came from our site for professional and enthusiast programmers.

  • “Currently, Facebook appears to strip query string parameters on pages shared that do not resolve as .html” - I think that might rather be a problem of your Open Graph meta tags. Make sure you set the og:url correctly. – CBroe Oct 27 '16 at 9:15
  • codex.wordpress.org/Rewrite_API/add_rewrite_rule - make a rule then parse the queries to handle the template loaded. – jgraup Oct 27 '16 at 15:17

You can do this quickly by creating a rule in .htaccess.

Log in to Wordpress and go to the page you want to link to.

Then click "preview changes".

Look for the preview_id parameter in the url.

And use this id after de index.php?p= in the .htaccess like:

# BEGIN WordPress

RewriteEngine On
RewriteBase /

RewriteRule ^mypage/page.html$ index.php?p=262 [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END Wordpress
  • Keep in mind that PHP can rewrite the .htaccess. By example when using WP SuperCache. So it is not the best solution. But it works. There are several ways to add this rule permanently to your htaccess. If needed i can help you with that too. – Alain Vanderbroeck Oct 27 '16 at 8:59
  • Hey Alain, Thank you for your solution! I would be interested to know how to add this rule permanently also. – user2743326 Oct 31 '16 at 13:11

It definitely works without .html, maybe try it like this:

  • Hey thanks for your comment, is there an easy way to do this for only 1 URL in Wordpress? I don't want to remove the trailing slash from all url's on an existing site. – user2743326 Oct 27 '16 at 8:19
  • only 1 URL? That may not be easy, of course you can hack it somehow, but that´s never a good idea... – luschn Oct 27 '16 at 8:24

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.