分享

写回答

发帖

[提问] 请问禁止ip访问的代码要加在htacess的什么地方

GoDaddy GoDaddy 1890 人阅读 | 3 人回复

发表于 2009-1-12 08:11:02 | 显示全部楼层 |阅读模式

有个贱人从前天开始每天一大早就在我的网站上戴着 就停留在主页哪也不去 一待就是一两小时 不知道要干什么所以想封了他
想在htacess中这句代码 但是不知道加在哪

order allow,deny
deny from xxx.xx.x.x
allow from all
以下是我原来的htacess文件 请问上面这句话要加在什么地方 我加在最后面试了下 但是连我自己都访问不了了
<FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$">
    order deny,allow
    deny from all
</FilesMatch>

RewriteEngine On
RewriteBase /

# direct one-word access
RewriteCond %{HTTP_HOST}  www. i.com

RewriteRule ^index.html$    index.php [L]
RewriteRule ^category$      index.php [L]

# access any object by its numeric identifier
RewriteRule ^feed-c([0-9]+).xml$       feed.php?cat=$1 [L]
RewriteRule ^feed-b([0-9]+).xml$       feed.php?brand=$1 [L]
RewriteRule ^feed.xml$                 feed.php [L]

RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$                            category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                                      category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$                                                       category.php?id=$1&brand=$2&page=$3  [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)(.*)\.html$                                                                category.php?id=$1&brand=$2  [QSA,L]
RewriteRule ^category-([0-9]+)(.*)\.html$                                                                          category.php?id=$1  [QSA,L]

RewriteRule ^goods-([0-9]+)(.*)\.html$  goods.php?id=$1 [QSA,L]

RewriteRule ^article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  article_cat.php?id=$1&page=$2&sort=$3&order=$4  [QSA,L]
RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*)\.html$                   article_cat.php?id=$1&page=$2   [QSA,L]
RewriteRule ^article_cat-([0-9]+)(.*)\.html$                            article_cat.php?id=$1   [QSA,L]

RewriteRule ^article-([0-9]+)(.*)\.html$                                article.php?id=$1   [QSA,L]

RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html   brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html                brand.php?id=$1&cat=$2&page=$3 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)(.*)\.html                         brand.php?id=$1&cat=$2 [QSA,L]
RewriteRule ^brand-([0-9]+)(.*)\.html                                   brand.php?id=$1 [QSA,L]

RewriteRule ^tag-(.*)\.html                                             search.php?keywords=$1 [QSA,L]
RewriteRule ^snatch-([0-9]+)\.html$                                      snatch.php?id=$1 [QSA,L]
RewriteRule ^group_buy-([0-9]+)\.html$                                   group_buy.php?act=view&id=$1 [QSA,L]
谁帮帮我 谢谢了

回答|共 3 个

add.c

发表于 2009-1-12 10:17:27 | 显示全部楼层

后面要加一句 allow from all

u34

发表于 2009-1-12 12:51:45 | 显示全部楼层

<FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$">
    order deny,allow
    deny from all
</FilesMatch>

order allow,deny                                             我把哪句代码加在这里了但是连我自己都访问不了了
deny from 115.192.211.33
allow from all

RewriteEngine On
RewriteBase /

# direct one-word access
RewriteCond %{HTTP_HOST}  www..com

RewriteRule ^index.html$    index.php [L]
RewriteRule ^category$      index.php [L]

# access any object by its numeric identifier
RewriteRule ^feed-c([0-9]+).xml$       feed.php?cat=$1 [L]
RewriteRule ^feed-b([0-9]+).xml$       feed.php?brand=$1 [L]
RewriteRule ^feed.xml$                 feed.php [L]

RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$                            category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                                      category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$                                                       category.php?id=$1&brand=$2&page=$3  [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)(.*)\.html$                                                                category.php?id=$1&brand=$2  [QSA,L]
RewriteRule ^category-([0-9]+)(.*)\.html$                                                                          category.php?id=$1  [QSA,L]
RAKSmart

大漠孤狼

发表于 2009-1-12 13:38:58 | 显示全部楼层

order deny,allow
deny from 123.45.6.7
allow from all

用这个,那个顺序写错了
您需要登录后才可以回帖 登录 | 注册

本版积分规则