开发者

.htaccess on specific filetypes

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

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

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

Other suggestio开发者_Python百科ns?

Thanks in advance


you can exclude existing files and directories

RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d

by placing this before your rule


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜