Hultin
Hultin

Reputation: 168

Redirect certain filetypes to another folder

My problem is this,

right now I have to link to /theme/css/somecssfile.css,

what I want to be able to do is this

/css/somecssfile.css, but still keep the physical file in /theme/.

This is my current .htaccess

# Enable Rewriting  
RewriteEngine on  
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Upvotes: 1

Views: 37

Answers (1)

anubhava
anubhava

Reputation: 786329

Insert this rule just below RewriteEngine On line:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?\.css)$ /theme/$1 [L,NC]

If you want to include .js also in this rule then use:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?\.(?:css|js))$ /theme/$1 [L,NC]

Upvotes: 1

Related Questions