简体   繁体   English

.htaccess自行更改-导致500内部服务器错误

[英].htaccess Changing Itself - Causing 500 Internal Server Error

I'm having issues with .htaccess changing itself and causing 500 - Internal Server Errors on my website. 我在.htaccess更改自身时出现问题,并在我的网站上导致500-内部服务器错误。 This change occurs every second day or so. 此更改大约每隔两天发生一次。

My original .htaccess file looks like this: 我的原始.htaccess文件如下所示:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

And after it changes itself, it looks like this: 更改后,它看起来像这样:

# BEGIN WordPress<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Essentially, this line is moved up to the end of the above line: 本质上,此行将移至上一行的末尾:

<IfModule mod_rewrite.c>

Our website was hacked a few weeks ago and used for phishing. 我们的网站在几周前被黑客入侵,并用于网络钓鱼。 Our host shut it down, and we made changes which they felt were good enough to re-open our website. 我们的主机将其关闭,我们进行了一些他们认为足以重新打开我们的网站的更改。 We changed... 我们改变了...

  • Updated to the latest version of Wordpress (we're normally up to date, but were a few days late on this). 已更新至最新版本的Wordpress(我们通常是最新的,但延迟了几天)。

  • Installed two security plug-ins (Better WP Security and Bulletproof Security). 安装了两个安全性插件(更好的WP Security和Bulletproof Security)。

  • As well as removing a forums plug-in which we believe COULD have been the cause of vulnerability. 以及删除我们认为可能导致漏洞的论坛插件。

  • Both security plug-ins have now been removed. 现在已删除了两个安全性插件。

  • I have now changed the permissions on the htaccess file 我现在已经更改了htaccess文件的权限

We can't really afford to have our site go down (500 server error) again. 我们真的负担不起再次使网站崩溃(500服务器错误)。 Is there anything I have missed that could be causing .htaccess to get changed? 我是否错过了可能导致.htaccess更改的任何内容? Note: When I replace the changed htaccess file with the original, it fixes the 500 server error. 注意:当我将更改后的htaccess文件替换为原始文件时,它可以修复500服务器错误。

Taking a quick look at your two security plug-ins, the Bulletproof Security does a lot of touching of your .htaccess file. 快速浏览一下您的两个安全性插件,Bulletproof Security对.htaccess文件进行了很多修改。 Personally, I would never let a plug-in touch .htaccess, because if there are any bugs in the plug-in, it can knock your site offline with a 500 server error. 就个人而言,我绝不会让插件接触.htaccess,因为如果插件中有任何错误,它可能会因500服务器错误而使您的站点脱机。

I would take a look at what the plug-in is trying to do in .htaccess and manually add that to the file, after disabling Bulletproof Security. 在禁用Bulletproof Security之后,我将看看该插件在.htaccess中尝试执行的操作并将其手动添加到文件中。

Alternatively, you could try adding an extra linespace between the initial comment and the following line, like this: 或者,您可以尝试在初始注释和下一行之间添加一个额外的行距,如下所示:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And lastly, you could do away with the "IfModule" altogether, since you know it's installed on your server: 最后,您可以完全取消“ IfModule”,因为您知道它已安装在服务器上:

# BEGIN WordPress

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

The problem is probably caused by the interaction between the two security plugins. 该问题可能是由于两个安全性插件之间的交互引起的。 Maybe disabling one of them will fix the problem. 也许禁用其中之一将解决问题。

Another way to secure your htaccess is assigning it to the root user (if you are allowed to) and/or make it read only. 保护htaccess的另一种方法是将其分配给root用户(如果允许)和/或使其只读。 Of course it does not solve the underlying problem, but at least the effects are contained. 当然,它不能解决潜在的问题,但是至少可以包含效果。

我遇到了同样的问题,但最终我发现.htaccess文件编码应保留在默认的ANSI ,并且错误仅是因为我将其编码更改为UTF8

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

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