Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

WordPress: How to Remove Extra Query Parameters from URLs

$
0
0

Crunchify Query String Parameter Example

In the World Wide Web, a query string is the part of a uniform resource locator (URL) that contains data to be passed to web applications such as PHP/ASP/CGI programs, hence WordPress.

A typical URL containing a query string is as follows:

http://example.com/category/post/?query_string

i.e.
http://example.com/category/post/?utm=ga 
http://example.com/category/post/?ref=pocket
...

When a server receives a request for such a page, it may run a program, passing the 

query_string
 unchanged to the program. The question mark is used as a separator and is not part of the query string. This is bad because it dilutes your link equity (SEO) and, in an ideal situation, you would like all URLs to point to the canonical version. Add this little snippet to your .htaccess file and it will strip the unnecessary query parameters from all incoming requests.
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{QUERY_STRING} !=""
 RewriteCond %{QUERY_STRING} !^p=.*
 RewriteCond %{QUERY_STRING} !^s=.*
 RewriteCond %{REQUEST_URI} !^/wp-admin.*
 RewriteRule ^(.*)$ /$1? [R=301,L]
</IfModule>

NOTE: If you are using Google Custom Search on your blog then you may want to avoid this tricks :) .

Are you looking for WordPress Tips? Find here list of more than 100 articles..

The post WordPress: How to Remove Extra Query Parameters from URLs appeared first on Crunchify.


Viewing all articles
Browse latest Browse all 1037

Trending Articles