RewriteCond:不支持非正则表达式'-f'的NoCase选项,将被忽略

Dav*_*Lee 3 mod-rewrite

以下是我的.htaccess.它运作良好,但我在error_log文件中出错:

[warn] RewriteCond:不支持非正则表达式'-f'的NoCase选项,将被忽略.

<Files .htaccess>
order allow,deny
deny from all
</Files>

#Options +FollowSymlinks
DirectoryIndex index.php
Options All -Indexes

RewriteEngine on
# remove trailing slash
RewriteRule ^(.*)/$ /$1 [L,R=301]

#Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^part_(\d+)$        /detail.php?id=$1 [NC]
RewriteRule ^find_(.+)$     /search.php?q=$1 [NC]
Run Code Online (Sandbox Code Playgroud)

小智 6

不确定这是否有帮助,但根据本网站,如果您在Apache错误日志中看到以下错误:

[warn] RewriteCond: NoCase option for non-regex pattern ‘-f’ is not 
       supported and will be ignored
Run Code Online (Sandbox Code Playgroud)

您应该更改.htaccess或中更改以下行httpd.conf

RewriteCond %{REQUEST_FILENAME} !-f [NC]
Run Code Online (Sandbox Code Playgroud)

RewriteCond %{REQUEST_FILENAME} !-f
Run Code Online (Sandbox Code Playgroud)

请注意[NC]该行末尾的缺失.