stackminu
stackminu

Reputation: 781

htaccess exclude CSS/JS/Images

This exclude CSS/JS/Images from original url. Anyone know how to solve this problem ?

.htacess:

RewriteEngine on
RewriteRule %{REQUEST_FILENAME} !-d
RewriteRule %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]

PHP:

$splitarray = explode('/',$_GET['uri']);

Upvotes: 2

Views: 3046

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

Try:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} \.(js|css|jpe?g|gif|png|bmp|ico)$ [NC]
RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]

So this will route through index.php if the request isn't for an existing directory and, the request isn't for an existing file OR the request isn't for a file ending with js, css, jpeg, jpg, gif, png, bmp, ico.

Upvotes: 3

Related Questions