Htaccess区分大小写的重写条件问题


Htaccess case sensitive rewrite condition issue

我为我的网站写了一个重写规则,如下所示;

 RewriteEngine on
 DirectoryIndex index.html index.php
 RewriteCond %{REQUEST_FILENAME} !-f [NC]
 RewriteCond %{REQUEST_FILENAME} !-d [NC]
 RewriteRule ^([^.php].+) /details.php?name=$0

当我尝试www.example.com/example时,它将被重定向到www.example.com/details.php?name=示例。但我尝试过访问类似的网站www.example.com/example,但失败了。

请告诉我如何解决这个问题?

您可以添加,

CheckSpelling on

摘要

CheckSpelling是一种更"宽容"的网站体验和卸载错误日志的好方法,因为它可以用于自动更正文件请求。激活后,此"拼写检查器"会将请求目录中的每个文档名称与请求的文档名称进行比较,而不考虑大小写,并且最多允许一个拼写错误(字符插入、省略、换位或错误字符)

启用拼写检查的示例CheckSpelling On.

参考Liink

实际上问题出现在您的规则中,该规则使用了不正确的正则表达式。

使用此规则:

RewriteEngine on
DirectoryIndex index.html index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /details.php?name=$1 [L,QSA]