What is the recommended method to hide query parameters in URLs for SEO purposes in PHP?

When query parameters are visible in URLs, it can expose sensitive information and negatively impact SEO. To hide query parameters in URLs for SEO purposes in PHP, one common method is to use URL rewriting techniques, such as mod_rewrite in Apache or the rewrite module in NGINX, to rewrite the URLs with query parameters into cleaner, more user-friendly URLs.

// Example of using mod_rewrite in Apache to hide query parameters in URLs
// Add this to your .htaccess file in the root directory of your website

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ /$1? [R=301,L]