never_had_a_name
never_had_a_name

Reputation: 93216

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 turn the rewrite engine off.

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

thanks

Upvotes: 3

Views: 5967

Answers (1)

zombat
zombat

Reputation: 94177

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.

Upvotes: 6

Related Questions