首页 > 解决方案 > 使 .htaccess 在符号链接目标文件夹中工作

问题描述

我使用 public_hmtl 中的符号链接来访问服务器上其他位置的文件夹中的脚本,但该文件夹有一个 .htaccess 文件,该文件阻止访问,如果我只是删除/禁用它,脚本将无法工作。

符号链接在这里:

/home/username/public_html/symlink

脚本目标文件夹在这里:

/家/目标

有没有办法让 .htaccess 文件在符号链接目标文件夹中工作?还是我应该把它移到别的地方?

我尝试将其添加到 .htaccess 文件中:

Options +FollowSymLinks

但这并没有做任何事情。显然我还必须把它放在 Apache 配置中的某个地方(?):

    # enable allowoverride privileges
    <Directory /home/target>
        AllowOverride Options
    </Directory>

但是我的 VPS 配置了 EasyApache4,所以我不应该手动编辑虚拟主机文件和方法以通过 WHM 产生错误来包含这些行。

我应该继续尝试 FollowSymLinks/AllowOverride 吗?或者这无论如何都是一个死胡同?还有其他解决方案吗?

为我的无知道歉。.htaccess 把我搞糊涂了。我不知道这些文件发生了什么。

编辑:

.htaccess 文件有以下几行:

RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

RewriteRule ^resetPassword$ /index.php?resetPassword=true
RewriteRule ^resetPassword/([^/\.]+)/?$ /index.php?resetPassword=true&hash=$1

RewriteRule ^install$ /index.php?install=true
RewriteRule ^install/([^/\.]+)/?$ /index.php?install=true

RewriteRule ^update /index.php?update=true
RewriteRule ^update/([^/\.]+)/?$ /index.php?update=true

RewriteRule ^/?$ /index.php?act=dashboard.show
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?act=$1.$2 [QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?act=$1.$2&id=$3 [QSA]

标签: apache.htaccesssymlink

解决方案


推荐阅读