2014-09-06 131 views
1

我不知道爲什麼,但這個簡單的規則將無法正常工作。簡單的重寫規則不工作在PHP/Apache的htaccess

<IfModule mod_rewrite.c> 
Options -MultiViews 
RewriteEngine On 
RewriteBase/
RewriteRule ^rubbellos\.png/$ rubbellos/rubbelbild_png.php [NC,L] 
RewriteRule ^rubbellos\.css/$ rubbellos/rubbellos_css.php [NC,L] 
</IfModule> 

如果我將xyz/rubbellos/rubbelbild_png.php複製到瀏覽器中,它是可以的。

我的做法是將rubbellos.png的請求帶到.php文件中。但是我找不到文件。

Thx任何提示提前。

回答

1

你有2個錯誤:

  • 使用RewriteBase因爲你談論你的問題的子目錄/xyz/
  • 禁用MultiViews選項可避免rubbellos(虛擬文件和現有目錄)發生意外行爲。

您可以通過這一個在你的htaccess的(這必須是在/xyz/文件夾)

注意替換當前的代碼:不要忘記你的真實子目錄的名稱,以取代xyz

+0

thx。我將它改爲上面的代碼。 RewriteBase在我的情況下是根。 – hamburger 2014-09-06 10:59:33