的.htaccess对特定文件类型文件类型、htaccess

2023-09-02 01:11:05 作者:北巷长歌悠

我在我的htaccess的一些神奇的东西。它的工作原理非常好,但我不知道该怎么

I have some magic stuff in my htaccess. It works very well but I don't know how

RewriteRule ^[^_+/]. index.php

我觉得它说,所有的请求应该通过的index.php无论哪个目录的游客要求。到目前为止,一切都很好。不过图像,CSS文件,JS文件等应当然不会被解析的index.php文件。我可以排除上述规则的某些目录?像/ IMG,/ ​​css和/ JS

I think it says that all requests should go through index.php no matter which directory the visitor ask for. So far so good. However images, css files, js files etc should of course not be parsed in index.php. Can I exclude certain directories from the above rule? Like /img, /css and /js

其他建议?

在此先感谢

推荐答案

您可以通过使用简单的RewriteCond避免请求某些路径...

You can avoid requests to certain paths by using a simple RewriteCond...

RewriteCond ${REQUEST_URI} !^css
RewriteCond %{REQUEST_URI} !^img
RewriteCond %{REQUEST_URI} !^js
# or alternatively just
RewriteCond ${REQUEST_URI} !^(css|img|js)
 
精彩推荐