不要重写静态css/js/img文件 [英] don't rewrite static css/js/img files

查看:99
本文介绍了不要重写静态css/js/img文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取htaccess文件,以免重写我的静态文件(js/css/images).

I'm trying to get my htaccess file not to rewrite my static files (js/css/images).

这是我当前的htaccess文件:

This is my current htaccess file:

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule    !\.(jpg|css|js|gif|png)$    public/    [L]
RewriteRule !\.(jpg|css|js|gif|png)$ public/index.php?url=$1

我如何重写它?

推荐答案

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*\.(jpg|css|js|gif|png)$ [NC]
RewriteRule ^(.*)$ public/index.php?url=$1

所有不以列出的扩展名结尾(不区分大小写)的不存在文件的请求都将重写为public/index.php,并将当前URL作为url= GET参数传递

All requests to not existing files which doesn't end with listed extensions (case nonsensitive match) are rewritten to public/index.php passing the current URL as url= GET argument

这篇关于不要重写静态css/js/img文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆