The direct implementation of what you ask would be this:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^docs/GENERAL_TERMS_AND_CONDITIONS\.pdf$
RewriteRule ^/?uploads/cms_files/GENERAL-TERMS-AND-CONDITIONS\.pdf https://example.com/uploads/cms_files/GENERAL-TERMS-AND-CONDITIONS.pdf [R=301,QSD]
That rule will work likewise in the http servers host configuration and in a dynamic configuration file (.htaccess
). If you decide to use a dynamic configuration file, then you have to take care that its interpretation is enabled at all (AllowOverride
directive), that such file is readable by the http server process and that it is located in the right location inside the http hosts document folder.
However why would you have to rewrite that at all? If an object exists that can be requested using that URL, then the query string can simply be ignored...
And a general hint: you should always prefer to place such rules inside the http servers (virtual) host configuration instead of using dynamic configuration files (.htaccess
style files). Those files are notoriously error prone, hard to debug and they really slow down the server. They are only supported as a last option for situations where you do not have control over the host configuration (read: really cheap hosting service providers) or if you have an application that relies on writing its own rewrite rules (which is an obvious security nightmare).