2017-10-06 74 views
1

一個獲取參數的在我的.htaccess我有以下規則被不創建API

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule productApi/(.*)$ productApi.php?category=$1 [QSA,NC,L] 
</IfModule> 

當我與MYSERVER/productAPI /布 要求給它裝上productAPI.php但是$ _REQUEST是空的,它本應是一個數組[「類別」 =>「布」]

我已經建立了對mod重寫trace8日誌和我得到以下日誌

add path info postfix: D:/myshop/productApi.php -> D:/myshop/productApi.php/cloths 
strip per-dir prefix: D:/myshop/productApi.php/cloths -> productApi.php/cloths 
applying pattern 'productApi/(.*)$' to uri 'productApi.php/cloths' 
pass through D:/myshop/productApi.php 
add path info postfix: D:/myshop/productApi.php -> D:/myshop/productApi.php/cloths 
strip per-dir prefix: D:/myshop/productApi.php/cloths -> productApi.php/cloths 
applying pattern 'productApi/(.*)$' to uri 'productApi.php/cloths' 
pass through D:/myshop/productApi.php 
strip per-dir prefix: D:/myshop/cloths -> cloths 
applying pattern 'productApi/(.*)$' to uri 'cloths' 
pass through D:/myshop/cloths 

我已經閱讀並改變了許多不同的東西,但它並沒有幫助我。 我不知道是什麼問題,但它如何處理重寫規則有問題。 任何幫助將不勝感激

回答

2

這很可能是由選項MultiViews造成的。

關閉它通過將該線在你的.htaccess的頂部:

Options -MultiViews 

選項MultiViews(見http://httpd.apache.org/docs/2.4/content-negotiation.html)所使用的Apache's content negotiation module運行mod_rewrite之前,使文件的Apache服務器匹配擴展。所以如果/file是URL,那麼Apache將服務於/file.html