Apache 重写规则“不”;贪婪的;足够地

Apache 重写规则“不”;贪婪的;足够地,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在尝试创建一个htaccess文件,该文件将显示一个简单的index.html,无论url是什么 文件夹结构 当有人提出要求时 /a/* or /a 我想提供index.html .htaccess文件已被删除 Options +FollowSymLinks RewriteEngine on RewriteRule ^a(.*) a/index.html [NC,L] RewriteRule ^a$ a/index.html [NC,L] 它可以在我的本地主机上工作,但不能在测试服务器

我正在尝试创建一个htaccess文件,该文件将显示一个简单的index.html,无论url是什么

文件夹结构 当有人提出要求时

/a/* or
/a
我想提供index.html

.htaccess文件已被删除

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^a(.*) a/index.html [NC,L]
RewriteRule ^a$ a/index.html [NC,L]
它可以在我的本地主机上工作,但不能在测试服务器上工作(Digitalocean上的默认Apache配置)

在我看来,这还不够“贪婪”。我做错了什么

我测试过的URL

/a/ <- works both locally (uwamp is local engine) and remotely
/a <- works both locally and remotely
/a/anything/ <- works locally but not on server

/a/如果您想将/a/中的所有内容重写为index.html,则将.htaccess放入文件夹/a就足够了/

Options +FollowSymlinks
RewriteEngine on
RewriteRule .* index.html [NC]
这样,网站的其他部分就不会受到重写的影响

另外,检查Apache上是否启用了重写,因为它是一个干净的安装。
默认的Ubuntu安装没有启用它。

附加规则:
重写规则^a$a/index.html[NC,L]
要匹配/a onlynope,我仍然找不到404。你能提供你测试过的可用/不可用的URL,本地和远程吗?@JanPapenbrock yes并验证它是否在根目录下,而不是在a目录下。
Options +FollowSymlinks
RewriteEngine on
RewriteRule .* index.html [NC]