如何在Apache mod_rewrite中设置条件块

如何在Apache mod_rewrite中设置条件块,apache,mod-rewrite,Apache,Mod Rewrite,我需要在apachemod_rewrite中设置3个条件块:一个用于/api文档,另一个用于/api,第三个用于其他所有内容。但我找不到我做错了什么,因为我无法让它像描述的那样工作 到目前为止,我已将文件.htaccess设置为: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} api-docs RewriteR

我需要在apachemod_rewrite中设置3个条件块:一个用于/api文档,另一个用于/api,第三个用于其他所有内容。但我找不到我做错了什么,因为我无法让它像描述的那样工作

到目前为止,我已将文件.htaccess设置为:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} api-docs
RewriteRule (.*) api-docs/$1 [C]

RewriteCond %{REQUEST_URI} api
RewriteRule ^api/(.*)$ server/api.php/$1 [L]

RewriteRule ^(.*)$ /index.html
但我得到了一个错误:

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary.
Apache和系统版本:

 Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.7

有人能帮我找到错误吗?

好吧,我在深入阅读Apache文档后找到了解决方案。主要的保护程序是结束标志,请参阅,以及您可以在最终结果中找到的其他更改

RewriteEngine On

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

RewriteCond %{REQUEST_URI} "api\/.*"
RewriteRule ^api\/(.*)$ server/api.php/$1 [END]

RewriteCond %{REQUEST_URI} !=api\/.*
RewriteRule ^ /index.html [L]
我希望这对那些使用Angular 2+并希望在后端和SPA同时使用相同Apache服务器的人有所帮助