2017-10-06 103 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