.htaccess希望410消失但得到403被禁止

时间:2013-06-14 08:34:42

标签: regex .htaccess redirect

我想为包括root在内的所有请求提供410“Gone”标头。我添加了这个.htaccess文件......

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteRule (.*) - [G,L]

适用于http://foo.bar/foo.html的请求< - 提供410!太棒了: - )

但如果我要求http://foo.bar/< - 提供403 Forbidden。不太好: - (

如何重写htaccess只是说一切都消失了?

1 个答案:

答案 0 :(得分:0)

好的。这是任何新门户的“默认.htaccess”文件。它完美地运作。明智地使用它:)(我的hotlink.jpg是一个粉红色的独角兽。你必须知道这个!):



RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteRule .* - [G,L,NC]

#DEFAULT PAGE/FILE DirectoryIndex /site_all/index.php?uid=$1 [QSA,L]

#PROTECT .htaccess AND .htpasswd FILES < files .htaccess="" > order allow,deny deny from all < /files > < files .htpasswd="" > order allow,deny deny from all < /files >

### HACKING AND DIRECT-ACCESS PREVENTION ###

#PREVENT DIRECT PAGE ACCESS RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://www.unclefoo.com/.*$ [NC]

#PREVENT HOTLINKS RewriteCond %{HTTP_REFERER} !^$ RewriteRule .(gif|jpg)$ http://www.unclefoo.com/site_data/pics/hotlink.jpg [R,L]

#PREVENT INVALID CHARS RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9.+_/-\?\=\&]+\ HTTP/ [NC] #RewriteRule .* - [F,NS,L]

#PREVENT ACCESS TO PHP.INI Order Deny,Allow Deny from All Allow from env=REDIRECT_STATUS

#PREVENT ACCESS TO INCLUDES DIR - TEST IF COMPROMISES WEB SERVER IF 3rd PARTY HOSTS!!! #RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /site_data/includes/ .*$ [NC] #RewriteCond %{REQUEST_FILENAME} ^.+.php$ #RewriteRule .* - [F,NS,L]

#PREVENT DOWNLOAD/HACK TOOLS USAGE RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR] RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR] RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR] RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR] RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR] RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR] RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR] RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR] RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR] RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR] RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR] RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR] RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR] RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR] RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR] RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR] RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR] RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR] RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR] RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR] RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR] RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR] RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR] RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR] RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR] RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR] RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR] RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR] RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR] RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR] RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR] RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR] RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR] RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR] RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR] RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR] RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR] RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] RewriteCond %{HTTP_USER_AGENT} ^Zeus RewriteRule ^.* - [F,L]


现在你明白了为什么在开始网站之前必须先了解一下apache和.htaccess? ;)
希望这有帮助!
第n编辑:好像你走了所以这里是我的“最后的话”:)
  - 提出这个问题here,你可能得到或不得得到比我能给予的更好的支持   - 您可能遇到的潜在问题:
  〜使用虚拟主机(并且没有设置RewriteOptions Inherit)   ~foo.com/也许真的被禁止了(例如你的默认页面是whatever.html,无权访问该文件)
  〜如上所述,但在某处有404和ErrorDocument 404 /err403.html设置   〜你有一个符号链接到你的“去了html”,但Options FollowSymLinks被禁用了   〜已经在多个文件中配置了相同的RewriteRule(例如.htaccess和httpd.conf),这会导致头痛 无论哪种方式,我建议您检查您网站的目录,路径设置,链接和sym链接,以确保所有文件都在那里并且可以访问。
作为解决方法,我会跳过RewriteRule并改为ErrorDocument 4XX /410.php('4XX'代表401,402,403,404等)。
仍然希望这有助于:)