
AWS サーバーがあります。Laravel プロジェクトをセットアップしましたが、正常に動作しています。プロジェクトは /var/www/MyProject の下にあり、myproject.com/public にアクセスすると、アプリケーションが表示されます (Apache のユーザー名とパスワードを入力後)。
しかし、ベース URL の myproject.com にアクセスすると、Apache テスト ページが表示されます。このページは表示したくありません。ベース URL にアクセスすると、アプリケーションに直接リダイレクトするだけです。Apache welcome.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 を開き、Web サイトへの永続的なリダイレクトを追加します。
<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