Remove Query String from 301 Redirect – htaccess


// 301 this: www.example.com.au/subdir-1/?query=string
// to this: www.example.com.au/subdir-2/
RewriteRule ^subdir-1(.*) https://www.example.com.au/subdir-2/? [L,R=301]

Query strings in URLs can be awesome for page functions, and other times extremely pesky. Especially if you dont want to carry over the value from the old/redirected page.

The above snippet can be added to your .htaccess file to remove the query string, upon a rewrite and additionally using a 301.

Want a Fast Server Like Mine?

GET VULTR!