How can CSS and JS files be properly accessed when using mod_rewrite in PHP?

When using mod_rewrite in PHP, the URLs for CSS and JS files may be rewritten, causing them to not load properly. To solve this issue, you can add a condition in your .htaccess file to exclude the rewriting of CSS and JS files. This can be done by checking if the requested file is a physical file using the RewriteCond %{REQUEST_FILENAME} !-f directive.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]