Apache HTACCESS导致错误404

Apache HTACCESS导致错误404,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我在一个子目录中有以下htaccess代码 Options +FollowSymlinks RewriteEngine on RewriteRule ^([0-9]+).html$ order-details.php?id=$1 [NC,L] 它很好用。问题是该目录中每隔一页就会出现一个错误404 example.com/sub/sub/123456.html链接工作正常。另外,example.com/sub/sub/工作正常,因为我在子目录中有一个索引文件。但是,example.com/su

我在一个子目录中有以下htaccess代码

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([0-9]+).html$ order-details.php?id=$1 [NC,L]
它很好用。问题是该目录中每隔一页就会出现一个错误404

example.com/sub/sub/123456.html链接工作正常。另外,example.com/sub/sub/工作正常,因为我在子目录中有一个索引文件。但是,example.com/sub/sub/anotherpage.html给出了错误404。删除htaccess解决了一个问题,带来了另一个问题


example.com/sub/sub/

您试图使用字母数字名称访问页面。 但是,在您的htaccess上,它只适用于数字

RewriteRule^([0-9]+).html$order details.php?id=$1[NC,L]
由于
[0-9]

如果要重定向alpha数值,必须使用另一个掩码。也许
[0-9A-Za-z]

您可以添加

RewriteCond %{REQUEST_FILENAME} !-f
添加到代码中,以确保忽略文件夹中存在的文件

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+).html$ order-details.php?id=$1 [NC,L]

现在工作。看起来我也必须删除
sub/sub/
中htaccess中的.php扩展名

因此,基本上您希望
123456.html
转到
order details.php
页面,但
anotherpage.html
仅显示该目录中存在的真实anotherpage.html页面?是的,我正是希望这样。我重命名的页面是数字页面。如上所述,123456.html用于转到order-details.php页面,而anotherpage.html用于显示该目录中存在的真实anotherpage.html页面。很有趣,它适用于除一个文件之外的所有其他文件:-o您确定文件名正确吗?这个代码应该有效。是的。文件名是正确的。如果我删除htaccess代码,链接工作正常。
.htaccess
文件在
sub/sub/
文件夹中?有其他配置吗?您使用的是哪个版本的apache?我刚刚在服务器上检查了这个,它工作得很好。