
ローカルで作成したLaravelのプロジェクトをさくらのライトプランのサーバにアップしたらInternal Server Errorが出た。
まず解決法
.htaccessが原因。RewriteBase /
を追記すると直った。
public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase / # ←これを追加
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
調べ方
・トップページは表示できて、それ以外のページが見られない。cssなどの存在するファイルは表示できる。
→ .htaccessが原因かなぁとあたりをつける。
・.htaccessを削除してファイルの存在しないURLにアクセスすると500エラーが404エラーに。
→ .htaccessでほぼ確定。
・さくらのコントロールパネル > アプリケーションの設定 > アクセスログの設定 > エラーログ からエラーを確認。
AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
→ Rerwiteで無限ループしているっぽいので修正。