How can mod_rewrite be used to redirect URLs in PHP?

Mod_rewrite can be used in PHP to redirect URLs by creating rewrite rules in the .htaccess file. These rules can be used to redirect incoming requests to a different URL based on certain conditions, such as matching a specific pattern or query string parameter. By using mod_rewrite, you can easily manage URL redirections without having to modify your PHP code.

RewriteEngine on
RewriteRule ^old-url$ /new-url [L,R=301]