2013-09-25 97 views
1

我的問題是這樣的,重定向某些文件類型到另一個文件夾

現在我有鏈接到/theme/css/somecssfile.css,

什麼,我希望能夠做的就是這個

/css/somecssfile.css,但仍將物理文件保存在/ theme /中。

這是我目前的.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] 

回答

1

插入這條規則略低於RewriteEngine On行:

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

如果你想包括.js也是在這個規則,然後使用:

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