上传到主机时出现Laravel .htaccess错误

时间:2016-06-02 04:15:00

标签: laravel

您的.htaccess文件就像这样

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</ IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder ...
RewriteCond% {REQUEST_FILENAME}! -d
RewriteRule ^ (. *) / $ / $ 1 [L, R = 301]
# Handle Front Controller ...
RewriteCond% {REQUEST_FILENAME}! -d
RewriteCond% {REQUEST_FILENAME}! -f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond% {HTTP: Authorization}.
RewriteRule. * - [E = HTTP_AUTHORIZATION:% {HTTP: Authorization}]
</ IfModule>

不知何故主机最多可达500个内部服务器错误

1 个答案:

答案 0 :(得分:0)

正确的.htaccess应如下所示:

<IfModule mod_rewrite.c>
  <IfModule mod_negotiation.c>
    Options -MultiViews
  </IfModule>
  RewriteEngine On
  # Redirect Trailing Slashes If Not A Folder ...
  RewriteCond %{REQUEST_FILENAME}! -d
  RewriteRule ^(.*)/$/$1 [L,R=301]
  # Handle Front Controller ...
  RewriteCond %{REQUEST_FILENAME}! -d
  RewriteCond %{REQUEST_FILENAME}! -f
  RewriteRule ^ index.php [L]
  # Handle Authorization Header
  RewriteCond %{HTTP: Authorization}.
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

规则中有太多空格打破了它们。不要添加任何空格以提高可读性。

PS:将来使用像www.htaccesscheck.com这样的.htaccess验证程序,并尝试解决显示的问题。