What is the difference between using ModeRewrite in Apache and in .htaccess?

When using ModRewrite in Apache, the configuration is set in the main server configuration file (httpd.conf) or in a VirtualHost block. On the other hand, when using ModRewrite in .htaccess, the configuration is placed in a .htaccess file located in the root directory of the website. The main difference is the scope of the configuration - Apache configuration applies globally to the server or specific virtual host, while .htaccess configuration applies only to the directory where the .htaccess file is located.

// Example of using ModRewrite in .htaccess file to redirect all requests to index.php
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]