.htaccess仅在特定文件夹中重定向


.htaccess redirect only within certain folder

我设置了一些文件夹,并对PHP扩展使用了基本的重写(其中URL不显示.PHP)(例如/public_html/folderA|/public_html/folderB)。

我现在已经设置了一些新文件夹,我不想将此重定向应用到这些文件夹(/public_html/folderC),但我不知道如何使重定向仅应用于某些路径?

您可以在public_html/folderC中添加一个.htaccess文件,其中包含:

RewriteEngine Off

你也可以写排除(在其他规则之前)

RewriteRule ^(public_html'/folderC)($|/) - [L]

注意[L],它将告诉重写引擎不要查找任何其他规则。