How to force .htaccess used for routing to not route .css, .js, .jpg, etc. files?

前端 未结 4 1786
無奈伤痛
無奈伤痛 2020-12-09 11:29

I have the following .htaccess file in a subdirectory of a site which allows me to route all URLs to index.php where I can parse them.

However, it\'s not al

4条回答
  •  伪装坚强ぢ
    2020-12-09 12:01

    RewriteCond %{REQUEST_FILENAME} !-f alone should be enough.

    Another option is t exclude specific files from the rewrite. From the TYPO3 packages:

    # Stop rewrite processing, if we are in the typo3/ directory.
    # For httpd.conf, use this line instead of the next one:
    # RewriteRule ^/TYPO3root/(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
    RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
    

    This rule should appear before your actual rewrite. It should be

    RewriteRule ^(public/|*\.css|*\.js|*\.png|*\.jpg|*\.gif|robots\.txt) - [L]
    

    in your case.

提交回复
热议问题