0

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

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

这适用于对http://foo.bar/foo.html <-- 提供 410 的请求!伟大的 :-)

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

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

4

1 回答 1

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 次编辑:似乎你走了,所以这是我的“遗言”:) -在这里
问这个问题,你可能会或可能不会得到比我能提供的更好的支持。 - 您可能遇到的潜在问题: 〜使用虚拟主机(并且没有设置)。 ~ foo.com/ 也许真的是被禁止的(例如,你的默认页面是whatever.html,并且没有访问该文件的权限) ~ 如上所述,但有一个 404 和某处的设置 ~ 你有一个符号链接到你的“gone html”但是被禁用 ~一样

RewriteOptions Inherit

ErrorDocument 404 /err403.html
Options FollowSymLinks
RewriteRule已经在多个文件中进行了配置(例如 .htaccess 和 httpd.conf),这会让人头疼

无论哪种方式,我都建议您检查您网站的目录、路径设置、链接和符号链接,以确保所有文件都在那里并且可以访问。
作为一种解决方法,我会跳过RewriteRuleand 会ErrorDocument 4XX /410.php代替('4XX' 代表 401、402、403、404 等)。
仍然希望这会有所帮助:)

于 2013-06-14T08:55:12.927 回答