htaccess显示索引中的内容,而不管条件如何

问题描述

这是htaccess内容

PHP_flag opcache.enable Off

Options -MultiViews
RewriteEngine on


#redirect from "/search.PHP?mc=123" to "master-123"
RewriteCond %{THE_REQUEST} /search.PHP\?mc=([^&]+)\sHTTP [NC]
RewriteRule ^ master-%1? [R=301,L,NE]
RewriteRule ^master-([^./]+)/?$ ?mc=$1 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

如果我从htaccess文件删除内容,则产品会正确加载,如果我添加了重写规则,它将正确地(从控制台)加载页面,但会显示index.PHP内容

解决方法

尝试以下规则:

Options -MultiViews
RewriteEngine on    

#redirect from "/search.php?mc=123" to "master-123"
RewriteCond %{THE_REQUEST} /search\.php\?mc=([^&]+)\s [NC]
RewriteRule ^ /master-%1? [R=301,L,NE]

RewriteRule ^master-([^./]+)/?$ search.php?mc=$1 [L,QSA,NC]