我在基本目录中有一个.htaccess文件,我有一些文件夹
folder1 folder2 folder3
在基本目录.htaccess中是否有一种方法可以添加一些仅用于的目录 folder1 folder2 folder3
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.m3u8 file.m3u8 [NC,L]
RewriteCond %{HTTP_USER_AGENT} ^.*(vlc|LibVLC|Android|iPhone).*$ [NC]
RewriteRule ^(.*)$ http://example.com [L,R=301]
所以我希望这些规则只针对这3个文件夹,而不是基本文件夹和其他文件夹
答案 0 :(得分:2)
您可以使用RewriteCond %{REQUEST_URI} ^/(folder1|folder2|folder3)/
定位某些目录:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(folder1|folder2|folder3)/ [NC]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.m3u8 file.m3u8 [NC,L]
RewriteCond %{REQUEST_URI} ^/(folder1|folder2|folder3)/ [NC]
RewriteCond %{HTTP_USER_AGENT} ^.*(vlc|LibVLC|Android|iPhone).*$ [NC]
RewriteRule ^ http://example.com [L,R=301]