.htaccess文件阻止加载索引页面

时间:2015-01-07 14:08:22

标签: .htaccess mod-rewrite internal-server-error

由于我是htacess的新用户所以我生成了htacesshere而下面是我的代码

Order allow,deny
<Files .htaccess .htpasswd .htuser .htgroups >
order allow,deny
deny from all
</Files>
<IfModule !mod_ssl.c>
Redirect permanent / https://www.domain.com/
</IfModule>
RewriteEngine  on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]  
RewriteCond %{HTTP_USER_AGENT} Wget [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerSE [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerElite [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailSiphon [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR] 
RewriteCond %{HTTP_USER_AGENT} ExtractorPro 
RewriteRule ^.*$ deny.html [L]
ErrorDocument 400 400.php
ErrorDocument 401 401.php
ErrorDocument 403 403.php
ErrorDocument 404 404.php
ErrorDocument 500 405.php
DirectoryIndex index.php

产生错误:

[Wed Jan 07 19:09:22.207084 2015] [core:alert] [pid 5032:tid 964] [client 200.195.156.150:43841] C:/wamp/www/.htaccess: Multiple <Files> arguments not (yet) supported.

并且错误mod_rewrite甚至已配置following method
当我删除mt htacess文件并运行我的服务器时我的索引页打开,所有ErrorDocument页面和htacess和索引页面都在root文件夹中可以任意一个帮帮我什么错误

2 个答案:

答案 0 :(得分:0)

尝试使用FilesMatch而不是Files,我认为这是产生错误的部分。

<FilesMatch "\.(htaccess|htpasswd|htuser|htgroups)$">
Order Allow,Deny
Deny from all
</FilesMatch>

我保留了其余的代码。

<IfModule !mod_ssl.c>
Redirect permanent / https://www.domain.com/
</IfModule>
RewriteEngine  on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]  
RewriteCond %{HTTP_USER_AGENT} Wget [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerSE [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerElite [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailSiphon [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR] 
RewriteCond %{HTTP_USER_AGENT} ExtractorPro 
RewriteRule ^.*$ deny.html [L]
ErrorDocument 400 400.php
ErrorDocument 401 401.php
ErrorDocument 403 403.php
ErrorDocument 404 404.php
ErrorDocument 500 405.php
DirectoryIndex index.php

答案 1 :(得分:-1)

从.htaccess中删除所有代码,只保留以下代码。

RewriteEngine  on
ErrorDocument 400 400.php
ErrorDocument 401 401.php
ErrorDocument 403 403.php
ErrorDocument 404 404.php
ErrorDocument 500 405.php
DirectoryIndex index.php