开发者

configure mod_rewrite to allow img, js and css files?

in my .htaccess i've got these lines:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

i tried to include js files with this line:

<script type="text/javascript" src="system/application/media/js/jquery/jquery.js"></script>

but it doesnt work since the rules dont let it pass. it works when i t开发者_如何转开发urn the rewrite engine off.

how can i change the rules so it allows url with a /js, /css and /img?

thanks


At another RewriteCond after your first one that will prevent your RewriteRule from matching. I sometimes filter on specific file extensions for static content files using the following rule:

RewriteCond $1 !\.(js|ico|gif|jpg|png|css|html|swf|mp3|wav|txt)$

If you want to do it based on directory, then you'll want something more like this:

RewriteCond $1 !^(css|js|img)/

Put one of those before your existing RewriteCond and you should be good to go.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜