.htaccess - htaccess 排除特定目录

标签 .htaccess mod-rewrite apache2.4

我的网站根目录有一个 htaccess,如下所示:

RewriteEngine On

RewriteRule \.php$ - [L,NC]

RewriteRule ^(?:favicon\.ico|(?:index|custom500|custom404)\.html)$ - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?source=$0 [L,QSA]

我希望它忽略那些包含特定文件夹 folder1 的 URL。网址将类似于:

https://mycooldomain.com/folder1/api/rest/... //something else here

我已经检查过this question但我似乎无法将其应用到我的情况。

最佳答案

像这样:

RewriteEngine On

# ignore request URLs that start with /folder1/
RewriteCond %{THE_REQUEST} \s/+folder1/ [NC]
RewriteRule ^ - [L]

RewriteRule \.php$ - [L,NC]

RewriteRule ^(?:favicon\.ico|(?:index|custom500|custom404)\.html)$ - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?source=$0 [L,QSA]

关于.htaccess - htaccess 排除特定目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69197835/

相关文章:

php - 在 ubuntu 12.04 上安装 apache 2.4 和 php 5.5

mod-wsgi - 在 Django/mod_wsgi 虚拟环境中配置 WSGIPythonHome 的问题

php - 如何阻止对目录中图像的直接访问但允许 PHP 显示它们?

php - 我真的可以对致命的解析错误无所事事吗?

regex - 带和不带斜杠

.htaccess - mod_rewrite/category.htm 成/category

.htaccess - 无法一点一点地验证域

.htaccess 在 URL 中带有 `#`

html - 在 .htaccess 中重写引擎以捕获不以 html 结尾的文件

tomcat - 为什么对象在 session 中丢失?