How can .htaccess be utilized to redirect URLs and process them with PHP in a WordPress installation?

To redirect URLs and process them with PHP in a WordPress installation using .htaccess, you can set up rewrite rules in the .htaccess file to redirect specific URLs to a PHP script. In the PHP script, you can then process the URL parameters and perform any necessary actions based on them.

# .htaccess
RewriteEngine On
RewriteRule ^custom-url/(.*)$ /index.php?custom_param=$1 [L]

# PHP script in index.php
if(isset($_GET['custom_param'])) {
    $custom_param = $_GET['custom_param'];
    
    // Process the custom parameter
    // Perform actions based on the parameter
}