Explain the role of .htaccess in WordPress.

The .htaccess file in WordPress handles URL redirection, permalinks, and security configurations. WordPress automatically writes basic permalink rules to .htaccess, but developers can manually add rules to optimize performance or improve security.