SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Optimising htaccess file

    My .htaccess file is pretty large, I'm hoping you can help me optimise it, I've added my comments, and I hope you can help correct my mistakes.

    Can I get php to handle the above instead of using html documents?

    For example;
    Code:
    RewriteRule ^errdoc/?$ errdoc.php [L]
    RewriteRule ^errdoc(.php)?/([0-9]+)/?$ errdoc.php?id=$2 [L] 
    ErrorDocument 400 http://www.somesite.com/errdoc.php/404
    The following is the part I really need optimising, I think most of this is duplicating - please be patient as it is very big.

    Code:
    # CodeRed 
    RewriteCond %{REQUEST_URI} ^/default.(ida|idq) [NC,OR] 
    RewriteCond %{REQUEST_URI} ^/.*.printer$ [NC,OR] 
    
    # Email 
    RewriteCond %{REQUEST_URI} (mail.?form|form|form.?mail|mail|mailto).(cgi|exe|pl)$ [NC,OR] 
    
    # MSOffice 
    RewriteCond %{REQUEST_URI} ^/(MSOffice|_vti) [NC,OR] 
    
    # Nimda 
    RewriteCond %{REQUEST_URI} /(admin|cmd|httpodbc|nsiislog|root|shell).(dll|exe) [NC,OR] 
    
    # Various 
    RewriteCond %{REQUEST_URI} ^/(bin/|cgi/|cgi-local/|sumthin) [NC,OR] 
    RewriteCond %{THE_REQUEST} ^GET http [NC,OR] 
    RewriteCond %{REQUEST_URI} /sensepost.exe [NC] 
    RewriteRule .* - [F] 
    
    # Forbid if blank (or "-") Referer *and* UA 
    RewriteCond %{HTTP_REFERER} ^-?$ 
    RewriteCond %{HTTP_USER_AGENT} ^-?$ 
    RewriteRule .* - [F] 
    
    # Banning BOTS below --------------------------------------------------------------------------------------
    SetEnvIfNoCase User-Agent "^BotRightHere" bad_bot
    SetEnvIfNoCase User-Agent "^[Ww]eb[Bb]andit" bad_bot
    SetEnvIfNoCase User-Agent "^Alexibot" bad_bot
    SetEnvIfNoCase User-Agent "^Aqua_Products" bad_bot
    SetEnvIfNoCase User-Agent "^asterias" bad_bot
    SetEnvIfNoCase User-Agent "^b2w/0.1" bad_bot
    SetEnvIfNoCase User-Agent "^BackDoorBot" bad_bot
    SetEnvIfNoCase User-Agent "^BackDoorBot/1.0" bad_bot
    SetEnvIfNoCase User-Agent "^Black.Hole" bad_bot
    SetEnvIfNoCase User-Agent "^BlackWidow" bad_bot
    SetEnvIfNoCase User-Agent "^BlowFish" bad_bot
    SetEnvIfNoCase User-Agent "^BlowFish/1.0" bad_bot
    SetEnvIfNoCase User-Agent "^Bookmark search tool" bad_bot
    SetEnvIfNoCase User-Agent "^BotALot" bad_bot
    SetEnvIfNoCase User-Agent "^BotRightHere" bad_bot
    SetEnvIfNoCase User-Agent "^BuiltBotTough" bad_bot
    SetEnvIfNoCase User-Agent "^Bullseye" bad_bot
    SetEnvIfNoCase User-Agent "^Bullseye/1.0" bad_bot
    SetEnvIfNoCase User-Agent "^BunnySlippers" bad_bot
    SetEnvIfNoCase User-Agent "^Cegbfeieh" bad_bot
    SetEnvIfNoCase User-Agent "^CheeseBot" bad_bot
    SetEnvIfNoCase User-Agent "^CherryPicker" bad_bot
    SetEnvIfNoCase User-Agent "^CherryPickerElite/1.0" bad_bot
    SetEnvIfNoCase User-Agent "^CherryPickerSE/1.0" bad_bot
    SetEnvIfNoCase User-Agent "^ChinaClaw" bad_bot
    SetEnvIfNoCase User-Agent "^Copernic" bad_bot
    SetEnvIfNoCase User-Agent "^CopyRightCheck" bad_bot
    SetEnvIfNoCase User-Agent "^Cosmos" bad_bot
    SetEnvIfNoCase User-Agent "^Crescent" bad_bot
    SetEnvIfNoCase User-Agent "^Crescent Internet ToolPak HTTP OLE Control v.1.0" bad_bot
    SetEnvIfNoCase User-Agent "^Custo" bad_bot
    SetEnvIfNoCase User-Agent "^DISCo" bad_bot
    SetEnvIfNoCase User-Agent "^DittoSpyder" bad_bot
    SetEnvIfNoCase User-Agent "^Download" bad_bot
    SetEnvIfNoCase User-Agent "^eCatch" bad_bot
    SetEnvIfNoCase User-Agent "^EirGrabber" bad_bot
    SetEnvIfNoCase User-Agent "^EmailCollector" bad_bot
    SetEnvIfNoCase User-Agent "^EmailSiphon" bad_bot
    SetEnvIfNoCase User-Agent "^EmailWolf" bad_bot
    SetEnvIfNoCase User-Agent "^EroCrawler" bad_bot
    SetEnvIfNoCase User-Agent "^Express" bad_bot
    SetEnvIfNoCase User-Agent "^ExtractorPro" bad_bot
    SetEnvIfNoCase User-Agent "^EyeNetIE" bad_bot
    SetEnvIfNoCase User-Agent "^FairAd Client" bad_bot
    SetEnvIfNoCase User-Agent "^Flaming AttackBot" bad_bot
    SetEnvIfNoCase User-Agent "^FlashGet" bad_bot
    SetEnvIfNoCase User-Agent "^Foobot" bad_bot
    SetEnvIfNoCase User-Agent "^FrontPage" bad_bot
    SetEnvIfNoCase User-Agent "^Gaisbot" bad_bot
    SetEnvIfNoCase User-Agent "^GetRight" bad_bot
    SetEnvIfNoCase User-Agent "^GetRight/4.2" bad_bot
    SetEnvIfNoCase User-Agent "^GetWeb!" bad_bot
    SetEnvIfNoCase User-Agent "^Go!Zilla" bad_bot
    SetEnvIfNoCase User-Agent "^Go-Ahead-Got-It" bad_bot
    SetEnvIfNoCase User-Agent "^GrabNet" bad_bot
    SetEnvIfNoCase User-Agent "^Grafula" bad_bot
    SetEnvIfNoCase User-Agent "^Harvest" bad_bot
    SetEnvIfNoCase User-Agent "^Harvest/1.5" bad_bot
    SetEnvIfNoCase User-Agent "^hloader" bad_bot
    SetEnvIfNoCase User-Agent "^HMView" bad_bot
    SetEnvIfNoCase User-Agent "^httplib" bad_bot
    SetEnvIfNoCase User-Agent "^HTTrack" bad_bot
    SetEnvIfNoCase User-Agent "^HTTrack 3.0" bad_bot
    SetEnvIfNoCase User-Agent "^humanlinks" bad_bot
    SetEnvIfNoCase User-Agent "^ia_archiver" bad_bot
    SetEnvIfNoCase User-Agent "^Image" bad_bot
    SetEnvIfNoCase User-Agent "^Indy" bad_bot
    SetEnvIfNoCase User-Agent "^InfoNaviRobot" bad_bot
    SetEnvIfNoCase User-Agent "^InterGET" bad_bot
    SetEnvIfNoCase User-Agent "^Internet" bad_bot
    SetEnvIfNoCase User-Agent "^Iron33/1.0.2" bad_bot
    SetEnvIfNoCase User-Agent "^JennyBot" bad_bot
    SetEnvIfNoCase User-Agent "^JetCar" bad_bot
    SetEnvIfNoCase User-Agent "^JOC" bad_bot
    SetEnvIfNoCase User-Agent "^Kenjin.Spider" bad_bot
    SetEnvIfNoCase User-Agent "^Keyword Density/0.9" bad_bot
    SetEnvIfNoCase User-Agent "^Keyword.Density" bad_bot
    SetEnvIfNoCase User-Agent "^larbin" bad_bot
    SetEnvIfNoCase User-Agent "^LexiBot" bad_bot
    SetEnvIfNoCase User-Agent "^libWeb/clsHTTP" bad_bot
    SetEnvIfNoCase User-Agent "^LinkextractorPro" bad_bot
    SetEnvIfNoCase User-Agent "^LinkScan/8.1a.Unix" bad_bot
    SetEnvIfNoCase User-Agent "^LinkWalker" bad_bot
    SetEnvIfNoCase User-Agent "^LNSpiderguy" bad_bot
    SetEnvIfNoCase User-Agent "^lwp-trivial" bad_bot
    SetEnvIfNoCase User-Agent "^lwp-trivial/1.34" bad_bot
    SetEnvIfNoCase User-Agent "^Mass" bad_bot
    SetEnvIfNoCase User-Agent "^Mata Hari" bad_bot
    SetEnvIfNoCase User-Agent "^Microsoft URL Control" bad_bot
    SetEnvIfNoCase User-Agent "^Microsoft URL Control - 5.01.4511" bad_bot
    SetEnvIfNoCase User-Agent "^Microsoft URL Control - 6.00.8169" bad_bot
    SetEnvIfNoCase User-Agent "^Microsoft.URL" bad_bot
    SetEnvIfNoCase User-Agent "^MIDown" bad_bot
    SetEnvIfNoCase User-Agent "^MIIxpc" bad_bot
    SetEnvIfNoCase User-Agent "^MIIxpc/4.2" bad_bot
    SetEnvIfNoCase User-Agent "^Mister" bad_bot
    SetEnvIfNoCase User-Agent "^Mister.PiX" bad_bot
    SetEnvIfNoCase User-Agent "^moget" bad_bot
    SetEnvIfNoCase User-Agent "^moget/2.1" bad_bot
    SetEnvIfNoCase User-Agent "^Mozilla.*NEWT" bad_bot
    SetEnvIfNoCase User-Agent "^Mozilla/2" bad_bot
    SetEnvIfNoCase User-Agent "^Mozilla/3.Mozilla/2.01" bad_bot
    SetEnvIfNoCase User-Agent "^Mozilla/4.0 (compatible; BullsEye; Windows 95)" bad_bot
    SetEnvIfNoCase User-Agent "^MS FrontPage" bad_bot
    SetEnvIfNoCase User-Agent "^MSIECrawler" bad_bot
    SetEnvIfNoCase User-Agent "^MSProxy/2.0" bad_bot
    SetEnvIfNoCase User-Agent "^Navroad" bad_bot
    SetEnvIfNoCase User-Agent "^NearSite" bad_bot
    SetEnvIfNoCase User-Agent "^Net" bad_bot
    SetEnvIfNoCase User-Agent "^NetAnts" bad_bot
    SetEnvIfNoCase User-Agent "^NetMechanic" bad_bot
    SetEnvIfNoCase User-Agent "^NetSpider" bad_bot
    SetEnvIfNoCase User-Agent "^NetZIP" bad_bot
    SetEnvIfNoCase User-Agent "^NICErsPRO" bad_bot
    SetEnvIfNoCase User-Agent "^NPBot" bad_bot
    SetEnvIfNoCase User-Agent "^Octopus" bad_bot
    SetEnvIfNoCase User-Agent "^Offline" bad_bot
    SetEnvIfNoCase User-Agent "^Offline.Explorer" bad_bot
    SetEnvIfNoCase User-Agent "^Openbot" bad_bot
    SetEnvIfNoCase User-Agent "^Openfind" bad_bot
    SetEnvIfNoCase User-Agent "^Openfind data gatherer" bad_bot
    SetEnvIfNoCase User-Agent "^Oracle Ultra Search" bad_bot
    SetEnvIfNoCase User-Agent "^PageGrabber" bad_bot
    SetEnvIfNoCase User-Agent "^Papa" bad_bot
    SetEnvIfNoCase User-Agent "^pavuk" bad_bot
    SetEnvIfNoCase User-Agent "^pcBrowser" bad_bot
    SetEnvIfNoCase User-Agent "^PerMan" bad_bot
    SetEnvIfNoCase User-Agent "^ProPowerBot/2.14" bad_bot
    SetEnvIfNoCase User-Agent "^ProWebWalker" bad_bot
    SetEnvIfNoCase User-Agent "^psbot" bad_bot
    SetEnvIfNoCase User-Agent "^Python-urllib" bad_bot
    SetEnvIfNoCase User-Agent "^QueryN.Metasearch" bad_bot
    SetEnvIfNoCase User-Agent "^Radiation Retriever 1.1" bad_bot
    SetEnvIfNoCase User-Agent "^ReGet" bad_bot
    SetEnvIfNoCase User-Agent "^RepoMonkey" bad_bot
    SetEnvIfNoCase User-Agent "^RepoMonkey Bait & Tackle/v1.01" bad_bot
    SetEnvIfNoCase User-Agent "^RMA" bad_bot
    SetEnvIfNoCase User-Agent "^searchpreview" bad_bot
    SetEnvIfNoCase User-Agent "^SiteSnagger" bad_bot
    SetEnvIfNoCase User-Agent "^SlySearch" bad_bot
    SetEnvIfNoCase User-Agent "^SmartDownload" bad_bot
    SetEnvIfNoCase User-Agent "^SpankBot" bad_bot
    SetEnvIfNoCase User-Agent "^spanner" bad_bot
    SetEnvIfNoCase User-Agent "^SuperBot" bad_bot
    SetEnvIfNoCase User-Agent "^SuperHTTP" bad_bot
    SetEnvIfNoCase User-Agent "^Surfbot" bad_bot
    SetEnvIfNoCase User-Agent "^suzuran" bad_bot
    SetEnvIfNoCase User-Agent "^Szukacz/1.4" bad_bot
    SetEnvIfNoCase User-Agent "^tAkeOut" bad_bot
    SetEnvIfNoCase User-Agent "^Teleport" bad_bot
    SetEnvIfNoCase User-Agent "^TeleportPro" bad_bot
    SetEnvIfNoCase User-Agent "^Telesoft" bad_bot
    SetEnvIfNoCase User-Agent "^The Intraformant" bad_bot
    SetEnvIfNoCase User-Agent "^The.Intraformant" bad_bot
    SetEnvIfNoCase User-Agent "^TheNomad" bad_bot
    SetEnvIfNoCase User-Agent "^TightTwatBot" bad_bot
    SetEnvIfNoCase User-Agent "^Titan" bad_bot
    SetEnvIfNoCase User-Agent "^toCrawl/UrlDispatcher" bad_bot
    SetEnvIfNoCase User-Agent "^True_Robot" bad_bot
    SetEnvIfNoCase User-Agent "^True_Robot/1.0" bad_bot
    SetEnvIfNoCase User-Agent "^turingos" bad_bot
    SetEnvIfNoCase User-Agent "^TurnitinBot" bad_bot
    SetEnvIfNoCase User-Agent "^TurnitinBot/1.5" bad_bot
    SetEnvIfNoCase User-Agent "^URL Control" bad_bot
    SetEnvIfNoCase User-Agent "^URL_Spider_Pro" bad_bot
    SetEnvIfNoCase User-Agent "^URLy.Warning" bad_bot
    SetEnvIfNoCase User-Agent "^VCI" bad_bot
    SetEnvIfNoCase User-Agent "^VCI WebViewer" bad_bot
    SetEnvIfNoCase User-Agent "^VCI WebViewer Win32" bad_bot
    SetEnvIfNoCase User-Agent "^VoidEYE" bad_bot
    SetEnvIfNoCase User-Agent "^Web" bad_bot
    SetEnvIfNoCase User-Agent "^Web.Image.Collector" bad_bot
    SetEnvIfNoCase User-Agent "^WebAuto" bad_bot
    SetEnvIfNoCase User-Agent "^WebBandit" bad_bot
    SetEnvIfNoCase User-Agent "^WebBandit/3.50" bad_bot
    SetEnvIfNoCase User-Agent "^WebCapture 2.0" bad_bot
    SetEnvIfNoCase User-Agent "^WebCopier" bad_bot
    SetEnvIfNoCase User-Agent "^WebCopier v.2.2" bad_bot
    SetEnvIfNoCase User-Agent "^WebCopier v3.2a" bad_bot
    SetEnvIfNoCase User-Agent "^WebEMailExtrac.*" bad_bot
    SetEnvIfNoCase User-Agent "^WebEnhancer" bad_bot
    SetEnvIfNoCase User-Agent "^WebFetch" bad_bot
    SetEnvIfNoCase User-Agent "^WebGo" bad_bot
    SetEnvIfNoCase User-Agent "^WebLeacher" bad_bot
    SetEnvIfNoCase User-Agent "^WebmasterWorldForumBot" bad_bot
    SetEnvIfNoCase User-Agent "^WebReaper" bad_bot
    SetEnvIfNoCase User-Agent "^WebSauger" bad_bot
    SetEnvIfNoCase User-Agent "^Website" bad_bot
    SetEnvIfNoCase User-Agent "^Website.Quester" bad_bot
    SetEnvIfNoCase User-Agent "^Webster Pro" bad_bot
    SetEnvIfNoCase User-Agent "^WebStripper" bad_bot
    SetEnvIfNoCase User-Agent "^WebWhacker" bad_bot
    SetEnvIfNoCase User-Agent "^WebZip" bad_bot
    SetEnvIfNoCase User-Agent "^WebZip/4.0" bad_bot
    SetEnvIfNoCase User-Agent "^WebZIP/4.21" bad_bot
    SetEnvIfNoCase User-Agent "^WebZIP/5.0" bad_bot
    SetEnvIfNoCase User-Agent "^Wget" bad_bot
    SetEnvIfNoCase User-Agent "^Wget/1.5.3" bad_bot
    SetEnvIfNoCase User-Agent "^Wget/1.6" bad_bot
    SetEnvIfNoCase User-Agent "^Widow" bad_bot
    SetEnvIfNoCase User-Agent "^WWW-Collector-E" bad_bot
    SetEnvIfNoCase User-Agent "^WWWOFFLE" bad_bot
    SetEnvIfNoCase User-Agent "^Xaldon" bad_bot
    SetEnvIfNoCase User-Agent "^Xenus" bad_bot
    SetEnvIfNoCase User-Agent "^Xenu's" bad_bot
    SetEnvIfNoCase User-Agent "^Xenu's Link Sleuth 1.1c" bad_bot
    SetEnvIfNoCase User-Agent "^Zeus" bad_bot
    SetEnvIfNoCase User-Agent "^Zeus 32297 Webster Pro V2.9 Win32" bad_bot
    SetEnvIfNoCase User-Agent "^Zeus Link Scout" bad_bot
    
    <Limit GET POST>
    Order Allow,Deny
    Allow from all
    Deny from env=bad_bot
    </Limit>
    
    # More BOTS below --------------------------------------------------------------------------------------
    
    # Address harvesters 
    RewriteCond %{HTTP_USER_AGENT} ^(autoemailspider|ExtractorPro) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^E?Mail.?(Collect|Harvest|Magnet|Reaper|Siphon|Sweeper|Wolf) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} (DTS.?Agent|Email.?Extrac) [NC,OR] 
    RewriteCond %{HTTP_REFERER} iaea.org [NC,OR] 
    
    # Download managers 
    RewriteCond %{HTTP_USER_AGENT} ^(Alligator|DA.?[0-9]|DC-Sakura|Download.?(Demon|Express|Master|Wonder)|FileHound) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Flash)Get [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Fresh|Lightning|Mass|Real|Smart|Speed|Star).?Download(er)? [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Gamespy|Go!Zilla|iGetter|JetCar|Net(Ants|Pumper)|SiteSnagger|Teleport.?Pro|WebReaper) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(My)?GetRight [NC,OR] 
    
    # Image-grabbers 
    RewriteCond %{HTTP_USER_AGENT} ^(AcoiRobot|FlickBot|webcollage) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Express|Mister|Web).?(Web|Pix|Image).?(Pictures|Collector)? [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Image.?(fetch|Stripper|Sucker) [NC,OR] 
    
    # "Gray-hats" 
    RewriteCond %{HTTP_USER_AGENT} ^(Atomz|BlackWidow|BlogBot|EasyDL|Marketwave|Sqworm|SurveyBot|Webclipping.com) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} (girafa.com|gossamer-threads.com|grub-client|Netcraft|Nutch) [NC,OR] 
    
    # Site-grabbers 
    RewriteCond %{HTTP_USER_AGENT} ^(eCatch|(Get|Super)Bot|Kapere|HTTrack|JOC|Offline|UtilMind|Xaldon) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Web.?(Auto|Cop|dup|Fetch|Filter|Gather|Go|Leach|Mine|Mirror|Pix|QL|RACE|Sauger) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Web.?(site.?(eXtractor|Quester)|Snake|ster|Strip|Suck|vac|walk|Whacker|ZIP) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} WebCapture [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^DISCo Pump [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Net Vampire [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^NetZIP [NC,OR] 
    
    # Tools 
    RewriteCond %{HTTP_USER_AGENT} ^(curl|Dart.?Communications|Enfish|htdig|Java|larbin) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} (FrontPage|Indy.?Library|RPT-HTTPClient) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(libwww|lwp|PHP|Python|www.thatrobotsite.com|webbandit|Wget|Zeus) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Microsoft|MFC).(Data|Internet|URL|WebDAV|Foundation).(Access|Explorer|Control|MiniRedir|Class) [NC,OR] 
    
    # Unknown 
    RewriteCond %{HTTP_USER_AGENT} ^(Crawl_Application|Lachesis|Nutscrape) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^[CDEFPRS](Browse|Eval|Surf) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Demo|Full.?Web|Lite|Production|Franklin|Missauga|Missigua).?(Bot|Locat) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} (efp@gmx.net|hhjhj@yahoo.com|lerly.net|mapfeatures.net|metacarta.com) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Industry|Internet|IUFW|Lincoln|Missouri|Program).?(Program|Explore|Web|State|College|Shareware) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Mac|Ram|Educate|WEP).?(Finder|Search) [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^(Moz+illa|MSIE).?[0-9]?.?[0-9]?[0-9]?$ [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[0-9].[0-9][0-9]?.(compatible[) ] [NC,OR] 
    RewriteCond %{HTTP_USER_AGENT} NaverRobot [NC] 
    RewriteRule .* - [F]

  2. #2
    SitePoint Columnist
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have access to run the rewrite rules from the master httpd.conf instead of from htaccess file? On the optimization side, this might help performance.
    Freelance System Administrator, Researcher, Writer
    Practical Applications
    Open Sourcery "SitePoint's Open Source Blog"

  3. #3
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, unfortuently not. I just thought that I might be replicating the stuff at the top with the stuff at the bottom.

  4. #4
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RewriteRule ^.htaccess$ - [F]
    is wrong, it should be:
    RewriteRule ^\.htaccess$ - [NC,F]

    .htaccess
    will match
    Ahtaccess
    1htaccess

    \.htaccess
    only match
    .htaccess

    ByTheWay,
    that's not usually necessary because, usually, within your httpd.conf, I know you cannot access it though, you have this:

    #
    # The following lines prevent .htaccess files from being viewed by
    # Web clients. Since .htaccess files often contain authorization
    # information, access is disallowed for security reasons. Comment
    # these lines out if you want Web visitors to see the contents of
    # .htaccess files. If you change the AccessFileName directive above,
    # be sure to make the corresponding changes here.
    #
    # Also, folks tend to use names such as .htpasswd for password
    # files, so this will protect those as well.
    #
    <Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
    </Files>
    so what you wrote is not necessary at all.
    Remove that rewrite rule and try to use:
    www.example.com/.htaccess
    you should not read the content of your .htaccess

    In case you can read the content of your .htaccess,
    then use the rule I wrote but make as your first priority the search of a new hosting company for your site
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  5. #5
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteRule ^.htaccess$ - [F]
    ErrorDocument 400 http://www.somesite.com/errDoc/400.htm
    ErrorDocument 401 http://www.somesite.com/errDoc/401.htm
    ErrorDocument 403 http://www.somesite.com/errDoc/403.htm
    ErrorDocument 404 http://www.somesite.com/errDoc/404.htm
    ErrorDocument 500 http://www.somesite.com/errDoc/500.htm
    ErrorDocument 501 http://www.somesite.com/errDoc/501.htm
    ErrorDocument 502 http://www.somesite.com/errDoc/502.htm
    ErrorDocument 503 http://www.somesite.com/errDoc/503.htm
    
    #Can I get php to handle the above instead of using html documents?
    
    #For example;
    #Code:
    
    #RewriteRule ^errdoc/?$ errdoc.php [L]
    #RewriteRule ^errdoc(.php)?/([0-9]+)/?$ errdoc.php?id=$2 [L] 
    #ErrorDocument 400 http://www.somesite.com/errdoc.php/404
    Why note just use:
    Code:
    ErrorDocument 400 /errdoc.php?id=400
    ErrorDocument 401 /errdoc.php?id=401
    ErrorDocument 403 /errdoc.php?id=403
    ErrorDocument 404 /errdoc.php?id=404
    ErrorDocument 500 /errdoc.php?id=500
    ErrorDocument 501 /errdoc.php?id=501
    ErrorDocument 502 /errdoc.php?id=502
    ErrorDocument 503 /errdoc.php?id=503
    ?!?
    Also using /errordoc.php?id=404 the address bar won't change,
    by using http://www.example.com/errdoc.php?id=404 your address bar will change...



    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  6. #6
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I commented by using this method

    ###your old rules
    ###my comment
    here_my_suggestion

    Code:
    # CodeRed 
    ###RewriteCond %{REQUEST_URI} ^/default.(ida|idq) [NC,OR]
    # Always remember to escape the dot...
    RewriteCond %{REQUEST_URI} ^/default\.(ida|idq) [NC,OR]
    ###RewriteCond %{REQUEST_URI} ^/.*.printer$ [NC,OR] 
    # Always remember to escape the dot...
    RewriteCond %{REQUEST_URI} ^/.*\.printer$ [NC,OR] 
    
    # Email 
    ###RewriteCond %{REQUEST_URI} (mail.?form|form|form.?mail|mail|mailto).(cgi|exe|pl)$ [NC,OR] 
    # Always remember to escape the dot...
    RewriteCond %{REQUEST_URI} (mail\.?form|form|form\.?mail|mail|mailto)\.(cgi|exe|pl)$ [NC,OR] 
    
    # MSOffice 
    RewriteCond %{REQUEST_URI} ^/(MSOffice|_vti) [NC,OR] 
    
    # Nimda 
    ###RewriteCond %{REQUEST_URI} /(admin|cmd|httpodbc|nsiislog|root|shell).(dll|exe) [NC,OR] 
    # Always remember to escape the dot...
    RewriteCond %{REQUEST_URI} /(admin|cmd|httpodbc|nsiislog|root|shell)\.(dll|exe) [NC,OR] 
    
    # Various 
    RewriteCond %{REQUEST_URI} ^/(bin/|cgi/|cgi-local/|sumthin) [NC,OR] 
    RewriteCond %{THE_REQUEST} ^GET http [NC,OR] 
    ###RewriteCond %{REQUEST_URI} /sensepost.exe [NC] 
    # Always remember to escape the dot...
    RewriteCond %{REQUEST_URI} /sensepost\.exe [NC] 
    ###RewriteRule .* - [F]
    # If you are going to forbidd then it's prudent to exit
    # from the rewrite engine, so I add the L (exit) flag...
    RewriteRule .* - [F,L] 
    
    # Forbid if blank (or "-") Referer *and* UA 
    RewriteCond %{HTTP_REFERER} ^-?$ 
    RewriteCond %{HTTP_USER_AGENT} ^-?$ 
    ###RewriteRule .* - [F] 
    # Comment as previously
    RewriteRule .* - [F,L]
    I want to poin that I never used those kind of deny,
    so mine was only a correction from a syntax point of view...




    p.s.
    I'm curios, where did you get those list of directives ?
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  7. #7
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks... (Sorry it took so long)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •