在提出问题之前让我告诉你一些假设这里有5个文件在我的web服务器上index.php config.php read.php write.php .htaccess
我在.htaccess中写了下面的URL重写规则
在RewriteRule上RewriteEngine ^(\ w +)$ read.php?id = $ 1
现在,当我键入domain.com/xyz它从read.php?id = xyz获取数据那很好:)
但是,当我键入domain.com/index它从index.php获取数据,或者当我键入domain.com/write或domain.com/config或domain.com/read它从write.php,config.php和读取数据.php分别
我希望数据从read.php?id = index或read.php?id = config或read.php?id = read或read.php?id = write
任何人都可以帮助我呢?
对不起,我英文很差
Options -multiviews
出于某种原因,您的原始规则必须有一个RewriteCond来检查文件是否存在。 由于多视图是,并且index.php确实存在,你已经请求索引,mod_negotiation会假设你想要index.php
您的规则将正常工作与closures多视图。
尝试这个…..
RewriteEngine On RewriteRule ^([a-zA-Z0-9 _-] +)/ $ read.php?id = $ 1
使用RewriteRule ^(。*)$ read.php?id = $ 1 [QSA,L]这样,所有请求都被重写