2009-11-18 122 views
0

這是一個非常愚蠢的問題,但我在htaccess中相當薄弱。.htaccess重定向到一個目錄

我想位於http://localhost/template/的所有文件(PHP,CSS,JavaScript和圖像)*指向http://localhost/ *與位於http://localhost/tempalte/404.php

我差點在這裏一個404錯誤處理一起,但是當我改變

RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1 [NC,L] to 
RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1.$2 [NC,L] 

我得到一個內部服務器錯誤。

# BEGIN website 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1 [NC,L] 
</IfModule> 

Options -Indexes 
# END website 

回答

1

編輯,以反映的意見,試試這個:

# BEGIN website 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} -f 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.*\.(css|php|js|png|gif)) template/$1 [NC,L] 
</IfModule> 

Options -Indexes 
# END website 
+0

喜DAV,它似乎沒有工作,我得到這個 請求的URL /login.php此服務器上找到。 – 2009-11-18 07:24:22

+0

你在瀏覽器中輸入什麼URL,以及你期望它加載的服務器上有什麼路徑? – Amber 2009-11-18 07:47:45

+0

讓我澄清一下我想在這裏確定的內容。通常當一個人說你想讓A指向B時,它意味着*實際上存在於B上的事物,並且A僅僅是一個實際上在B上的東西的鏈接。在上面的回答中,我遵循你指定的話語(你希望包含/ template /的URL指向*根目錄中存在的*)。然而,從你的例子來判斷,我想知道你的意思是你想讓根目錄中的URL指向* /存在於* /目錄中的東西嗎? – Amber 2009-11-18 07:52:52