What is mod_rewrite and how is it used in PHP?

Mod_rewrite is an Apache module used for URL rewriting. It allows you to manipulate URLs and redirect them to different locations. In PHP, mod_rewrite is commonly used to create clean and user-friendly URLs for websites.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1