【问题标题】:Site shows 500 internal error when after installation安装后站点显示 500 内部错误
【发布时间】:2018-06-19 09:56:41
【问题描述】:

我在我的 1and1 Web 服务器上安装了一个 php 脚本,但它显示 500 内部服务器错误,但是当 index.php 包含在 url 中时,它会加载正常的 index.php 主页。 网址是http://my.gsix.com.ng/,但是当它以这种方式输入http://my.gsix.com.ng/index.php时,它会加载正常的主页。

我还发现,当我第一次在我的本地主机上安装它时,它加载得很好。

编辑:

我的.htaccess 文件

RewriteCond $1 !^(index.php|assets|images|js|css|uploads|favicon.png|install|sitemap.xml|robots.txt) 
RewriteCond %(REQUEST_FILENAME) !-f 
RewriteCond %(REQUEST_FILENAME) !-d 
RewriteRule ^(.*)$ index.php?/$1 [L]

【问题讨论】:

  • 然后向我们展示您的 .htaccess 文件可能是个好主意
  • RewriteCond $1 !^(index.php|assets|images|js|css|uploads|favicon.png|install|sitemap.xml|robots.txt) RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule ^(.*)$ index.php?/$1 [L]
  • 那么您认为 .htaccess 有什么问题?

标签: php .htaccess


【解决方案1】:

这意味着php脚本包含一些错误,在脚本之上尝试这个

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

它会显示你需要修复的错误。

您可以尝试删除 .htaccess(它可能会重定向到不存在的页面)

【讨论】:

  • 之所以有效,是因为它是一个真实文件,他的 .htaccess 正在重定向他的路线,例如 /login
【解决方案2】:

你需要添加.htaccess文件

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.+$ /index.php [L]

解释:

这会启用重写引擎:

RewriteEngine on

这会检查现有文件夹 (-d) 和文件 (-f):

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

这会进行实际的重定向:

RewriteRule . index.php [L]

这会将每个查询重定向到根目录的 index.php

【讨论】:

  • 我的 htaccess 中打开了 RewriteEngine
  • 你有 RewriteBase / 吗?
  • @MichaelAyoLee 你能提供你的 .htaccess 文件吗
  • RewriteEngine on RewriteCond $1 !^(index.php|assets|images|js|css|uploads|favicon.png|install|sitemap.xml|robots.txt) RewriteCond %(REQUEST_FILENAME) !- f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule ^(.*)$ index.php?/$1 [L] @mooga
  • @MichaelAyoLee 1 美元是多少?你能试着让它 RewriteEngine on
猜你喜欢
  • 2014-03-23
  • 1970-01-01
  • 2016-12-28
  • 2020-01-03
  • 1970-01-01
  • 1970-01-01
  • 2020-03-16
  • 2016-01-11
  • 2013-10-16
相关资源
最近更新 更多