2014-03-07 93 views
0

是否可以創建一個匹配現有目錄的規則? 如下面的例子:與目錄名稱匹配的重寫別名?

RewriteRule ^foo$ foo.php 

考慮,這也是一個名爲「foo」的文件夾,阿帕奇試圖打開目錄,而不是解析規則。規則是否可能位於目錄之前?

謝謝

測試與以下配置:

Options +FollowSymlinks 
Options -MultiViews 
RewriteEngine on 
AddDefaultCharset iso-8859-1 
RewriteRule ^foo$ foo.php 

而且從阿帕奇收到以下錯誤:週五三月07 15點06分34秒2014] [警惕] [客戶端127.0.0.1 ] C:/htdocs/www.acasa.org.br.v2/.htaccess:選擇多視圖不在這裏

回答

0

您需要使用-MultiViews它忽略文件夾允許的。通過使用

DirectorySlash Off 

但是解決您的圖像問題建議的方法是::

Options +FollowSymLinks -MultiViews 

RewriteEngine On 
RewriteRule ^foo/?$ foo.php [L] 

您可以切換上DirectorySlash和關閉

<base href="http://www.domain.com/" /> 
+0

添加-MultiViews Apache是​​後返回錯誤: 內部服務器錯誤 服務器遇到內部錯誤或配置錯誤,無法完成您的請求。 – fcaserio

+0

@fcaserio和什麼是你的整個'.htaccess'內容?以及'error_log'上顯示的錯誤信息是什麼?確保'foo.php'工作。 – Prix

+0

apache日誌上的錯誤消息: [Fri Mar 07 15:08:30 2014] [alert] [client 127.0.0.1] C:/htdocs/www.acasa.org.br.v2/.htaccess:Option MultiViews not允許在這裏。 這是的.htaccess: 選項+的FollowSymLinks 選項-MultiViews RewriteEngine敘述上 AddDefaultCharset ISO-8859-1 重寫規則^ imprensa $ \t press_release.php – fcaserio