简体   繁体   English

从xamp移到专用服务器时出现500 Internal Server Error

[英]500 Internal Server Error when move from xamp to a dedicated server

Basically I have this lines into my .htaccess of my personal computer using xamp 基本上我使用xamp将这行输入到我的个人计算机的.htaccess中

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

Whats append? 追加了什么? Im moving to my dedicated server using apache2 on Debian 8.4 And the server gave me the next Error. 我在Debian 8.4上使用apache2移动到我的专用服务器,该服务器给了我一个下一个错误。 Why thats append? 为什么要追加?

Internal Server Error 内部服务器错误

The server encountered an internal error or misconfiguration and was unable to complete your request. 服务器遇到内部错误或配置错误,无法完成您的请求。

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error. 请通过webmaster @ localhost与服务器管理员联系,以告知他们该错误发生的时间以及您在此错误发生之前执行的操作。

More information about this error may be available in the server error log. 服务器错误日志中可能会提供有关此错误的更多信息。

Sounds like mod_rewrite is not enabled in Apache. 听起来好像在Apache中未启用mod_rewrite。 To enable it: 要启用它:

a2enmod rewrite
service apache2 restart

Such a mistake may happen because of lack of <ifModule mod_rewrite.c> construction, because this module might not be installed. 由于缺少<ifModule mod_rewrite.c>构造,可能会发生这种错误,因为可能未安装此模块。 So, you can add this condition, but mind that it won't solve your problem - you need the module installed to have redirects. 因此,您可以添加此条件,但是请注意,它不会解决您的问题-您需要安装模块才能重定向。

Update: 更新:

So, for now you'd better change code to: 因此,现在您最好将代码更改为:

<ifModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([^/]+)/$ $1.php
  RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
  RewriteRule (.*)$ /$1/ [R=301,L]
</IfModule>

Read more on Apache Docs 进一步了解Apache Docs

Then you need to switch the mod_rewrite module, you can read example here: How to install the Apache mod_rewrite module It's more of the system administrating sphere rather than of programming. 然后您需要切换mod_rewrite模块,您可以在此处阅读示例: 如何安装Apache mod_rewrite模块这更多的是系统管理领域,而不是编程领域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM