我知道有很多类似的帖子,但经过 3 个小时的研究,我仍然找不到解决方案。希望有人能帮忙。
使用的技术:
- Apache/2.4.7 (Ubuntu) 拉
- 拉维尔 5.4
- 菲律宾比索 7.0
/etc/apache2/site-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin stanley@example.com
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 时,它显示"/parcgilley 的索引"。当我导航到 http://www.example.com/parcgilley/public/时,Chrome 会显示"此页面无法正常工作"。
这是我的公共/.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。我不知道这是否与这个问题有关。
您是否尝试过通过 .htaccess 禁用目录列表?
Options -Indexes
以下是更多信息: https://www.thesitewizard.com/apache/prevent-directory-listing-htaccess.shtml