Redirecting Parameters

Referencing Parameter for Sub Directory


#Redirect Blog ID Parameter to Friendly URL
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^id=([\w-]+)$
RewriteRule ^blog\.php$ /blog/%1/? [R=301,L]

The example above will match and use the parameter as the sub directory for the destination URL

eg.
http://example.com/blog.php?id=hello-world => http://example.com/blog/hello-world


Redirecting A Specific Parameter


#Redirect Parameters to Friendly URL
RewriteCond %{QUERY_STRING} ^id=10$
RewriteRule ^index.php$ https://example.com/destination-url/? [R=301,L]

The example above will match index.php?id=10 and redirect it to https://example.com/destination-url/
(removing the parameter completely)


Remove Query String from 301 Redirect


# 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]

Want a Fast Server Like Mine?

GET VULTR!