Q&A
環境:Vagrant
ホストOS:Amazon Linux 2
WEBサーバ: Apache 2.4
Laravel 9
Vagrantの仮想マシンにApache 、Laravel をインストールして
ブラウザから https://192.168.33.10
や https://192.168.33.10/
で仮想マシンのWEBサーバにアクセスするとLaravelの画面が表示されると期待していたのですが、実際はステータスコード 403 が返ってきてApacheのデフォルトの画面?("Test Page for the Apache HTTP Server")が表示されます。
https://192.168.33.10/index.php
だとLaravelの画面が表示されます。
下に示した httpd.conf の33行目の AllowOverride All
で .htaccess が使えるようになって、Laravelのpublicディレクトリの .htaccess によって / にアクセスした場合は index.php が実行されてLaravelの画面が表示される、と自分では思っていたのですが。
https://192.168.33.10
や https://192.168.33.10/
でもLaravelの画面が表示されるようにするにはどうすればいいでしょうか?
Apache の httpd.conf と、変更していないのですが Laravel の public の .htaccess は以下です。
httpd.conf(コメントは削除)
1ServerRoot "/etc/httpd" 2 3Listen 80 4 5Include conf.modules.d/*.conf 6 7User apache 8Group apache 9 10 11ServerAdmin root@localhost 12 13 14<Directory /> 15 AllowOverride none 16 Require all denied 17</Directory> 18 19 20DocumentRoot "/var/www/html/src/laravel/public" 21 22<Directory "/var/www"> 23 AllowOverride None 24 Require all granted 25</Directory> 26 27<Directory "/var/www/html"> 28 <FilesMatch \.(html|php)$> 29 SetHandler "proxy:unix:/var/run/php-fpm/php-fpm.sock|fcgi://localhost" 30 </FilesMatch> 31 Options Indexes FollowSymLinks 32 33 AllowOverride All 34 35 Require all granted 36</Directory> 37 38<IfModule dir_module> 39 DirectoryIndex index.html 40</IfModule> 41 42<Files ".ht*"> 43 Require all denied 44</Files> 45 46ErrorLog "logs/error_log" 47 48LogLevel warn 49 50<IfModule log_config_module> 51 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 52 LogFormat "%h %l %u %t \"%r\" %>s %b" common 53 54 <IfModule logio_module> 55 # You need to enable mod_logio.c to use %I and %O 56 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 57 </IfModule> 58 59 60 CustomLog "logs/access_log" combined 61</IfModule> 62 63<IfModule alias_module> 64 65 66 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 67 68</IfModule> 69 70<Directory "/var/www/cgi-bin"> 71 AllowOverride None 72 Options None 73 Require all granted 74</Directory> 75 76<IfModule mime_module> 77 TypesConfig /etc/mime.types 78 79 AddType application/x-compress .Z 80 AddType application/x-gzip .gz .tgz 81 82 83 84 AddType text/html .shtml 85 AddOutputFilter INCLUDES .shtml 86</IfModule> 87 88AddDefaultCharset UTF-8 89 90<IfModule mime_magic_module> 91 MIMEMagicFile conf/magic 92</IfModule> 93 94 95EnableSendfile on 96 97 98<IfModule mod_http2.c> 99 Protocols h2 h2c http/1.1 100</IfModule> 101 102 103IncludeOptional conf.d/*.conf
Laravel
1<IfModule mod_rewrite.c> 2 <IfModule mod_negotiation.c> 3 Options -MultiViews -Indexes 4 </IfModule> 5 6 RewriteEngine On 7 8 # Handle Authorization Header 9 RewriteCond %{HTTP:Authorization} . 10 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 12 # Redirect Trailing Slashes If Not A Folder... 13 RewriteCond %{REQUEST_FILENAME} !-d 14 RewriteCond %{REQUEST_URI} (.+)/$ 15 RewriteRule ^ %1 [L,R=301] 16 17 # Send Requests To Front Controller... 18 RewriteCond %{REQUEST_FILENAME} !-d 19 RewriteCond %{REQUEST_FILENAME} !-f 20 RewriteRule ^ index.php [L] 21</IfModule>
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。