如何从 .htaccess 中排除子文件夹

发布于 2024-09-30 17:47:19 字数 514 浏览 1 评论 0原文

我正在使用插件用户访问管理器来限制对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七七 2024-10-07 17:47:19

将 .htaccess 文件放入 wpsc/ 文件夹中,其内容如下:

<IfModule mod_rewrite.c>
RewriteEngine Off
RewriteBase /
</IfModule>

这会否决父文件夹中 .htaccess 文件中的重写规则

这适用于插件 WP Photo Album Plus,即 ../wp -content/uploads/wppa/ 文件夹。

Place a .htaccess file in the wpsc/ folder with the content:

<IfModule mod_rewrite.c>
RewriteEngine Off
RewriteBase /
</IfModule>

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.

§普罗旺斯的薰衣草 2024-10-07 17:47:19

您可以使用 RewriteCond 检查匹配的字符串:

RewriteCond $1 !^wpsc/
RewriteRule (.*) /index.php?uamfiletype=attachment&uamgetfile=$1 [L]

You can inspect the matched string with a RewriteCond:

RewriteCond $1 !^wpsc/
RewriteRule (.*) /index.php?uamfiletype=attachment&uamgetfile=$1 [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文