简体   繁体   English

.htaccess文件给出500个内部服务器错误

[英].htaccess file gives 500 internal server error

I receive 500 internal server error on my website. 我在网站上收到500个内部服务器错误。 I think this is because of .htaccess file, but I don't know what's wrong with it. 我认为这是由于.htaccess文件引起的,但我不知道它怎么了。

Server: DirectAdmin, Linux-based 服务器:DirectAdmin,基于Linux

Contents of the .htaccess file is as the following: .htaccess文件的内容如下:

# BEGIN All In One WP Security
#AIOWPS_BLOCK_WP_FILE_ACCESS_START
<files license.txt>
order allow,deny
deny from all
</files>
<files wp-config-sample.php>
order allow,deny
deny from all
</files>
<files readme.html>
order allow,deny
deny from all
</files>

#AIOWPS_BLOCK_WP_FILE_ACCESS_END
#AIOWPS_BASIC_HTACCESS_RULES_START
<files .htaccess>
order allow,deny
deny from all
</files>
ServerSignature Off
LimitRequestBody 10240000
<files wp-config.php>
order allow,deny
deny from all
</files>
#AIOWPS_BASIC_HTACCESS_RULES_END
#AIOWPS_PINGBACK_HTACCESS_RULES_START
<IfModule mod_alias.c>
RedirectMatch 403 /(.*)/xmlrpc\.php$
</IfModule>
#AIOWPS_PINGBACK_HTACCESS_RULES_END
#AIOWPS_DISABLE_INDEX_VIEWS_START
Options All -Indexes
#AIOWPS_DISABLE_INDEX_VIEWS_END
#AIOWPS_DISABLE_TRACE_TRACK_START
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
#AIOWPS_DISABLE_TRACE_TRACK_END
#AIOWPS_FIVE_G_BLACKLIST_START
# 5G BLACKLIST/FIREWALL (2013)
# @ http://perishablepress.com/5g-blacklist-2013/

# 5G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (\\|\.\./|`|='$|=%27$) [NC,OR]
RewriteCond %{QUERY_STRING} (\;|'|\"|%22).*(union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR]
RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR]
RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC]
RewriteRule .* - [F]
</IfModule>

# 5G:[USER AGENTS]
<IfModule mod_setenvif.c>
# SetEnvIfNoCase User-Agent ^$ keep_out
SetEnvIfNoCase User-Agent (binlar|casper|cmsworldmap|comodo|diavol|dotbot|feedfinder|flicky|ia_archiver|jakarta|kmccrew|nutch|planetwork|purebot|pycurl|skygrid|sucker|turnit|vikspider|zmeu) keep_out
<limit GET POST PUT>
Order Allow,Deny
Allow from all
Deny from env=keep_out
</limit>
</IfModule>

# 5G:[REQUEST STRINGS]
<IfModule mod_alias.c>
RedirectMatch 403 (https?|ftp|php)\://
RedirectMatch 403 /(https?|ima|ucp)/
RedirectMatch 403 /(Permanent|Better)$
RedirectMatch 403 (\=\\\'|\=\\%27|/\\\'/?|\)\.css\()$
RedirectMatch 403 (\,|\)\+|/\,/|\{0\}|\(/\(|\.\.\.|\+\+\+|\||\\\"\\\")
RedirectMatch 403 \.(cgi|asp|aspx|cfg|dll|exe|jsp|mdb|sql|ini|rar)$
RedirectMatch 403 /(contac|fpw|install|pingserver|register)\.php$
RedirectMatch 403 (base64|crossdomain|localhost|wwwroot|e107\_)
RedirectMatch 403 (eval\(|\_vti\_|\(null\)|echo.*kae|config\.xml)
RedirectMatch 403 \.well\-known/host\-meta
RedirectMatch 403 /function\.array\-rand
RedirectMatch 403 \)\;\$\(this\)\.html\(
RedirectMatch 403 proc/self/environ
RedirectMatch 403 msnbot\.htm\)\.\_
RedirectMatch 403 /ref\.outcontrol
RedirectMatch 403 com\_cropimage
RedirectMatch 403 indonesia\.htm
RedirectMatch 403 \{\$itemURL\}
RedirectMatch 403 function\(\)
RedirectMatch 403 labels\.rdf
RedirectMatch 403 /playing.php
RedirectMatch 403 muieblackcat
</IfModule>

# 5G:[REQUEST METHOD]
<ifModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>

# 5G:[BAD IPS]
<limit GET POST PUT>
Order Allow,Deny
Allow from all
# uncomment/edit/repeat next line to block IPs
# Deny from 123.456.789
</limit>
#AIOWPS_FIVE_G_BLACKLIST_END
#AIOWPS_BLOCK_SPAMBOTS_START
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
RewriteCond %{HTTP_REFERER} !^http://(.*)?\.spna\.co\.ir [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* http://127.0.0.1 [L]
</IfModule>
#AIOWPS_BLOCK_SPAMBOTS_END
# END All In One WP Security

# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# 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 here's what the Apache Error Log says: 这就是Apache错误日志的内容:

[Thu Jan 16 00:19:08 2014] [alert] [client 157.55.35.85] /home/sapna/domains/spna.co.ir/public_html/.htaccess: Option All not allowed here

I would be grateful if you help me find out what causes the 500 internal server error. 如果您能帮助我找出导致500内部服务器错误的原因,将不胜感激。

Thanks. 谢谢。

Often 500 Internal Server Error happens if you fail to load the mod_rewrite module. 如果无法加载mod_rewrite模块,通常会发生500 Internal Server Error

To enable RewriteEngine On you need to run the following command: 要启用RewriteEngine On,您需要运行以下命令:

sudo a2enmod rewrite

In Local mechine 在本地机器中

  1. Create your project folder. 创建您的项目文件夹。

  2. Create .htaccess file in your project root directory like below. 在项目根目录中创建.htaccess文件,如下所示。

.htaccess .htaccess

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
  1. Save .htaccess file. 保存.htaccess文件。
  2. Now click on wamp / lamp / xamp server icon and click on apache and select "rewire_module". 现在单击wamp / lamp / xamp服务器图标,然后单击apache并选择“ rewire_module”。

In Cpanel 在Cpanel中

  1. Directly you need to create .htaccess file with above code and save. 直接您需要使用上述代码创建.htaccess文件并保存。

Note: - Please don't write any spelling mistakes in cpanel. 注意:-请不要在cpanel中写任何拼写错误。 If you write any spelling mistakes it will gives you an internal server error (500). 如果您输入任何拼写错误,它将给您内部服务器错误(500)。

Problem is this line due to your Apache cnfig: 问题是由于您的Apache cnfig这行:

Options All -Indexes

change this to: 更改为:

Options -Indexes

I was facing same problem, here is solution for ubuntu and apache It was because mod_rewrite module was not enabled , First enable module rewrite: 我遇到了同样的问题,这是ubuntu和apache的解决方案这是因为未启用mod_rewrite模块 ,首先启用模块重写:

sudo a2enmod rewrite 

And restart apache 并重新启动apache

sudo systemctl restart apache2

Now edit for directory level 现在编辑目录级别

sudo vim /etc/apache2/sites-enabled/000-default.conf

add these lines at end 在末尾添加这些行

<Directory /var/www/html>
    AllowOverride All
 </Directory>

and restart apache again. 然后重新启动apache。

sudo service apache2 restart

确保您具有AllowOverride Options特权才能使用Options

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

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