.htaccess 问题,无法访问 Apache


.htaccess issue with no access to Apache

如上所述,我们接到了一个项目的任务,但被告知它必须上传到大学服务器,并且还必须使用大学数据库(绝对荒谬)。

我开始使用框架开发应用程序:Laravel。不幸的是,我遇到了一个障碍,因为我相信大学 Apache 服务器正在引起问题,但我无法证明这一点,因为我对所有这些重写内容仍然陌生。

我确信Apache Rewrite已启用。

我的大学 html 文件系统目录如下:

/home/nt***/public_html/

要访问这些文件,我们必须导航到(我已经删除了实际地址):

RewriteRule ^(.*)$ http://universitywebsite.ac.uk/~nt***/public/index.php

现在,无论出于何种原因,转到地址:http://universitywebsite.ac.uk/~nt***/public/会自动将我重定向到:http://universitywebsite.ac.uk/public这是由他们的阿帕奇设置引起的吗?如果是这样,有没有办法解决它?

尽管如此,我还是可以使用以下.htaccess文件:

RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ http://universitywebsite.ac.uk/~nt***/public/index.php/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://universitywebsite.ac.uk/~nt***/public/index.php [L]

它适用于除基本 http://universitywebsite.ac.uk/~nt***/public/之外的所有内容,因为这仍然重定向我。请求 uri 如下:REQUEST_URI/~nt****/user/login。这显然是行不通的。因为这不是正确的文件系统目录。

我好糊涂!很抱歉我缺乏知识,如果我能帮上任何其他帮助,请告诉我。

第二个规则不应在目标 URI 中http://以进行内部重写。试试这个作为第二条规则:

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /~nt***/public/index.php [L]