如何从 .htaccess 中排除子文件夹
我正在使用插件用户访问管理器来限制对 WordPress 站点中上传的文件夹的访问。 此文件夹位于 example.com/wp-content/uploads/。 该插件已将此 .htaccess 写入该文件夹中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) /index.php?uamfiletype=attachment&uamgetfile=$1 [L]
</IfModule>
在该文件夹 (/wp-content/uploads/) 中,还有一个名为 wpsc 的文件夹 (/wp-content/uploads/wpsc/),其中包含网站商店的文件。 现在 .htaccess 工作正常,但它也限制了 wpsc 文件夹。我需要添加一个例外,以便每个人都可以访问 wpsc 文件夹。
I'm using the plugin User Access Manager to restrict access to the folder uploads in a Wordpress site.
This folder is located at example.com/wp-content/uploads/.
The plugin has written this .htaccess in that folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) /index.php?uamfiletype=attachment&uamgetfile=$1 [L]
</IfModule>
In that folder (/wp-content/uploads/) there is also a folder called wpsc (/wp-content/uploads/wpsc/) with the files of the shop of the site.
Right now the .htaccess is working fine, but it's restricting the wpsc folder too. I need to add an exception so the wpsc folder can be accessed by everybody.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 .htaccess 文件放入 wpsc/ 文件夹中,其内容如下:
这会否决父文件夹中 .htaccess 文件中的重写规则
这适用于插件 WP Photo Album Plus,即 ../wp -content/uploads/wppa/ 文件夹。
Place a .htaccess file in the wpsc/ folder with the content:
This overrules the rewriterule in the .htaccess file in the parent folder
This works for the plugin WP Photo Album Plus, i.c. the ../wp-content/uploads/wppa/ folder.
您可以使用
RewriteCond
检查匹配的字符串:You can inspect the matched string with a
RewriteCond
: