在子文件夹中安装Laravel但主页显示索引

问题描述 投票:0回答:1

我知道有很多类似的帖子,但经过3个小时的研究后,我仍然无法找到解决方案。希望有人能提供帮助。

使用的技术:

  • Apache / 2.4.7(Ubuntu)
  • Laravel 5.4
  • PHP 7.0

/etc/Apache2/site-enabled/000-default.conf

<VirtualHost *:80>
        ServerAdmin [email protected]
        Servername example.com
        DocumentRoot /var/www/html/example.com
        <Directory />
                Options +FollowSymLinks
                #AllowOverride None
                Require all granted
        </Directory>
        <Directory /var/www/html/example.com/>
                Options +Indexes +FollowSymLinks +MultiViews
                AllowOverride All
                Require all granted
        </Directory>

        <Directory "/var/www/html/example.com/parcgilley/public">
                Options Includes Indexes FollowSymLinks
                DirectoryIndex index.php
                Order allow,deny
                Allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI +MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    .......

所以文档根位于/var/www/html/example.com,我的laravel站点位于/var/www/html/example.com/parcgilley。我尝试配置000-default.conf将我的网站指向/var/www/html/example.com/parcgilley/public,但是当我访问example.com/parcgilley时,它会显示“index of / parcgilley”。当我导航到http://www.example.com/parcgilley/public/时,Chrome会显示“此页面无效”。

这是我的public / .htaccess文件:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

这不是原始内容。我按照Laravel的说明进行操作,所以我用上面的代码替换了原点。

另外,我已经为/ parcgilley项目根文件夹和存储文件夹设置了权限,但无济于事。

我不知道是否需要创建.htaccess文件以指向/ public文件夹。但我对apache配置知之甚少。

任何见解将不胜感激。

编辑:

此外,我使用SSH和Git将网站从我的本地机器推送到服务器,只需在/var/repo/site.git上选择。我不知道这是否与这个问题有关。

php apache .htaccess laravel-5
1个回答
0
投票

您是否尝试通过.htaccess禁用目录列表?

Options -Indexes

这里有更多信息:https://www.thesitewizard.com/apache/prevent-directory-listing-htaccess.shtml

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.