2014-02-15 69 views
1

我需要將所有調用從example.com/files/改爲example.com/app/files/,無需任何重定向(URL重定向)。htaccess將一個文件夾替換爲另一個

調用可能包含子目錄和css,js,png,jpg文件。

like。

example.com/files/css/style.css

example.com/files/js/script.js

example.com/files/image/background.png

example.com/files/upload/prof/1.jpg

在同我需要添加這段代碼(codeigniter index.php removel)。

<IfModule mod_rewrite.c> 
     RewriteEngine On 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteRule ^(.*)$ index.php?/$1 [L] 
    </IfModule> 

    <IfModule !mod_rewrite.c> 
     ErrorDocument 404 /index.php 
    </IfModule> 
+0

你能否澄清一點更象你想靜態和非靜態的文件瀏覽器中顯示的網址是什麼? – anubhava

回答

1

你的htaccess應該是這樣的

ErrorDocument 404 /index.php 
RewriteEngine On 

RewriteRule ^files/(.+)$ /app/files/$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php?/$1 [L] 
+0

完美地工作。謝謝... –

相關問題