
我有一個AWS伺服器。我建立了一個 Laravel 項目,並且運作良好。該專案位於 /var/www/MyProject 下,當我訪問 myproject.com/public 時,我看到了該應用程式(輸入我的 apache 使用者名稱和密碼後)。
但是,當我僅訪問基本 URL myproject.com 時,我會看到 Apache 測試頁面。我不想看到這個頁面。當我轉到基本 URL 時,我只想直接重定向到應用程式。我提交了 Apachewelcome.conf 文件中的所有文本,這刪除了啟動頁面,但我收到了一條禁止訪問的消息。
這是我的虛擬主機:
# Laravel 8 base install test
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/myproject"
ServerName myproject.com
<Directory "/var/www/myproject/public">
Options Indexes FollowSymLinks
#DirectoryIndex index.php
AllowOverride All
AuthBasicProvider file
AuthUserFile /etc/httpd/conf.d/.htpasswd
AuthType Basic
AuthName "Auth"
Require valid-user
</Directory>
# Protect development directories from prying eyes.
RewriteEngine On
RewriteRule (^|/)docs(/|$) - [F]
RewriteRule (^|/)node_modules(/|$) - [F]
#RewriteRule (^|/)vendor(/|$) - [F]
</VirtualHost>
答案1
我想到了。
開啟 /etc/httpd/conf.d/welcome.conf 並新增永久重定向到網站:
<LocationMatch "^/+$">
Redirect permanent / https://myproject.com #Added this line
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html