I am focusing on Wordpress website and anytime I add url params towards the url, it redirects the page to some version with no params.


http://mysite.com/?foo=bar -> redirects to -> http://mysite.com/

http://mysite.com/contact-us/?foo=bar -> redirects to http://mysite.com/contact-us/

How do i fix this? We want certain params to load using the page for a number of reasons.

Items in .htaccess (edited to include QSA - which is not working):

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,QSA]

# END WordPress

Make use of query_vars to reach that goal. WordPress stores all of the query string parameters that it could need inside a global object also it ignores anything else.

You have to instruct it to complete the next:

  • Instruct WordPress in order to save your variables. You give a filter to query_vars to achieve that. A good example is succumbed the hyperlink below.
  • Retrieve your computer data using $wp_query->query_vars['customvariable'] rather than the standard _GET or _POST.

The particulars are available here: http://codex.wordpress.org/Custom_Queries#Custom_Archives

Add the "query string append" (QSA) flag towards the finish of the rewrite rules.

'qsappendQSA' (query string append) This flag forces the rewrite engine to append a question string area of the substitution string towards the existing string, rather than changing it. Make use of this when you wish to increase the data towards the query string using a rewrite rule.

RewriteRule . /index.php [L,QSA]

# Without QSA: http://mysite.com/contact-us/?foo=bar →
#   http://mysite.com/index.php?page_name=contact-us
# With QSA: http://mysite.com/contact-us/?foo=bar →
#   http://mysite.com/index.php?page_name=contact-us&foo=bar

Begin to see the Apache documentation to learn more.