我的网站根目录有一个 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/