## This .htaccess file should go into the root directory of our public website.
## Another .htaccess goes into the dokuwiki subdirectory of the website.
## For instructions on using ModRewrite see the following:
##   http://httpd.apache.org/docs/current/mod/mod_rewrite.html
##   http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/

## Write expires headers on all resources
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access plus 3 months"
  ExpiresByType image/jpeg "access plus 3 months"
  ExpiresByType image/gif "access plus 3 months"
  ExpiresByType image/png "access plus 3 months"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType text/x-javascript "access plus 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
  ExpiresByType image/x-icon "access plus 3 months"
  ExpiresDefault "access plus 5 days"
</IfModule>

## Deny some forum login bots:
<Limit GET POST PUT>
order allow,deny
## For testing, the Mosaic office IP is 96.86.191.213 (static.hfc.comcastbusiness.net)
deny from 103.229.125.20
deny from 64.79.85.202 
allow from all
</Limit>

RewriteEngine on

# bad-bots.deny is a list of host names or ip addresses, one per line
# 
# RewriteMap bad-bots-deny txt:/bad-bots.deny
# RewriteCond ${bad-bots-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
# RewriteCond ${bad-bots-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
# RewriteRule ^/.* - [F] 


## I tried the following to provide case insensitivity, but it didn't work (crashed the server)
# <IfModule mod_speling.c>
#   CheckCaseOnly On
#   CheckSpelling On
# </IfModule>

## For public wikis block some nuisance robots with the following.  This won't block the
## really bad robots as they're dishonest in reporting their identity in their user
## agent string:
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Custo [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^DISCo [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^eCatch [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^GetRight [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Grafula [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^HMView [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} Indy.Library [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^InterGET [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^JetCar [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^larbin [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Navroad [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^NearSite [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Octopus [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^pavuk [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^ReGet [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Widow [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^xpymep.exe [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^xrumer.exe [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^BotMaster [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^LYCOSA [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Zeus 
RewriteCond %{HTTP_USER_AGENT} ^Niki-Bot
RewriteRule ^.*$ http://english-1400282245.spampoison.com [R=301,L]
## The above line redirects to an anti-spam site full of fake email addresses
## But we also could have simply died silently using the following rewrite instead:
# RewriteRule ^.*$ - [F,L]

RewriteCond %{HTTP_USER_AGENT} ^Sogou [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^imbot [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^ShopWiki [NC]
RewriteRule ^.*$ - [F,L]

## Other bots we may consider banning are: 008,2dayhost.com,8484\ Boston\ Project,A1\ Website\ Download,Aboundexbot,AboutUsBot,accelobot,accelovation,AdBot,agbot,AhrefsBot,amazon,amazonaws.com,archive.org,archive.orgbot,archive.org_bot,atraxbot,attributor,Baiduspider,Baiduspider-image,Baiduspider-video,Bender,CamontSpider,CazoodleBot,ccbot,CCBot/1.0,charlotte.betaspider,cogent,COMODOspider,Covario-IDS,CovarioIDS,crawler.archive.org,Creative\ AutoUpdate,discobot,DOC,dotbot,dotnetdotcom,Download\ Ninja,dropdowndeals,Exabot,eZooms,FAST\ ESP\ Document\ Retriever/CVS,Fetch,findfiles.net\ ,Findfiles.net/0.98,Getleft\ 1.2,gigabot,Gootkit\ auto-rooter\ scanner,GosoSpider,grub-client,heratix,heratrix,heretix,heritrix,HopperBot,HTTrack,ia_archiver,ichiro/2.0,ilial,IsraBot,itsapic.com_crawler,JikeSpider,k2spider,kimsufi.com,LemurProject\ Nutch\ Spider,libwww,linko,LiteFinder,MaxPointCrawler,Microsoft.URL.Control,MJ12bot,MLBot,MSIECrawler,MSR-ISRCCrawler,MSRPUTNIK,mvk-it.com,naverbot,NerdByNature.Bot,Netseer,NextGenSearchBot,NPBot,Nutch,openx,Orthogaffe,PageNest,pik-a-part,pikimal,proximic,ProxyWay.com,psbot,ptd-crawler,purebot,Purebot,QBikSpider,Ripper,SBIder/SBIder-0.8.2-dev,ScoutJet,SemrushBot,SemrushBot/0.9,SeznamBot,ShablastBot,ShopWiki,sistrix,sitebot,sitecheck.internetseer.com,sixtrix,SoftByteLabs.com,sogou,spbot,Speedy,spider06.yandex.ru,Squid-Prefetch,suggybot,swebot,swish-e,TeleportPro,TreEZy,TurnitinBot,twtelecom.net,UbiCrawler,UbiCrawler,viglink,viglink/Nutch-1.0,WebAlta,webcrawler,WebPix,WebsiteInformation,Webster\ Pro\ v3.4,WebStripper,WebZIP,Wells\ Search\ II,Wep,wget,Wget/1.10\ devel,Wget/1.10.2,Wget/1.12,WinHTTP,WOW64,Xenu,YandexBot/3.0,Yanga\ Worldsearch\ Bot\ v1.1/beta,YETI,your-server.de,YRSPider,Zao,Zealbot,Zermelo,ZyBORG

## *******************************************************************************************************
## For testing at mosaic-website.circuit-design.info we replace these rewrites with those following:

## We rewrite to our cannonical url
 RewriteCond %{HTTP_HOST} !^www\.mosaic-industries\.com [NC]
 RewriteCond %{HTTP_HOST} !^$
 RewriteRule ^(.*)$ http://www.mosaic-industries.com/$1 [R=301,L]

## We rewrite to our cannonical url
#RewriteCond %{HTTP_HOST} !^mosaic-website\.circuit-design\.info [NC]
#RewriteCond %{HTTP_HOST} !^$
#RewriteRule ^(.*)$ http://mosaic-website.circuit-design.info/$1 [R=301,L]

#RewriteCond %{HTTP_HOST} !^mosaic-industries\.pretetsky\.com [NC]
#RewriteCond %{HTTP_HOST} !^$
#RewriteRule ^(.*)$ http://mosaic-industries.pretetsky.com/$1 [R=301,L]
## *******************************************************************************************************

RewriteCond %{THE_REQUEST} ^.*/index\.[xs]?html?
RewriteRule ^(.*)index\.[xs]?html?$ http://www.mosaic-industries.com/$1 [QSA,L,NC,R=301]
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.mosaic-industries.com/$1 [QSA,L,NC,R=301]

## Rewrite for the embedded-systems sitemap.  Using a rewrite rule allows us to place
## a top level url for the sitemap in the robots.txt file that google can use.
RewriteRule ^embedded-sitemap.xml$ http://www.mosaic-industries.com/embedded-systems/sitemap?do=sitemap [L,NC]

RewriteRule ^xyz/(.*)$ http://www.mosaic-industries.com/$1 [R=301,L,NC]
RewriteRule ^xyz$ http://www.mosaic-industries.com/News/Careers.html [R=301,L,NC]

## Rewrite rules for some broken links to us from other sites or from Google's index:
RewriteRule ^%3EMosaic%20Industries%3C/A%3E%20make%20single%20board%20computers%20for%20embedded%20applications.%3CLI%3E%20%3CA%20HREF=$ http://www.mosaic-industries.com/Products/SBC/ [R=301,L,NC]
RewriteRule ^(.*)measure-distance-sensorThis$ http://www.mosaic-industries.com/$1measure-distance-sensor  [R=301,L,NC]
RewriteRule ^.*%3E.*$ http://www.mosaic-industries.com [R=301,L,NC]
RewriteRule ^12V$ http://www.mosaic-industries.com [R=301,L,NC]
RewriteRule ^about/$ http://www.mosaic-industries.com/About/Profile.html [R=301,L]
RewriteRule ^about/profile.html$ http://www.mosaic-industries.com/About/ [R=301,L,NC]
RewriteRule ^analog\.html$ http://www.mosaic-industries.com/Products/WildCards/Analog%20IO/ [R=301,L,NC]
RewriteRule ^article/.*$ http://www.mosaic-industries.com/embedded-systems [R=301,L,NC]
RewriteRule ^careers.html$ http://www.mosaic-industries.com/News/Careers.html [R=301,L,NC]
RewriteRule ^News/careers.html$ http://www.mosaic-industries.com/News/Careers.html [R=301,L]
RewriteRule ^careers$ http://www.mosaic-industries.com/News/Careers.html [R=301,L,NC]
RewriteRule ^jobs$ http://www.mosaic-industries.com/News/Careers.html [R=301,L,NC]
RewriteRule ^embedded-s$ http://www.mosaic-industries.com/embedded-systems/microcontroller [R=301,L,NC]
RewriteRule ^embedded-Systems$ http://www.mosaic-industries.com/embedded-systems/microcontroller [R=301,L,NC]
RewriteRule ^embedded-syste\..*$ http://www.mosaic-industries.com/embedded-systems [R=301,L,NC]
RewriteRule ^embedded-web$ http://www.mosaic-industries.com/embedded-web-server.html [R=301,L,NC]
RewriteRule ^embedded-web-server$ http://www.mosaic-industries.com/embedded-web-server.html [R=301,L,NC]
RewriteRule ^embedded\.\..*$ http://www.mosaic-industries.com/embedded-systems [R=301,L,NC]
RewriteRule ^Main/$ / [R=301,L,NC]
RewriteRule ^manuals/$ http://www.mosaic-industries.com/Manuals/ [R=301,L]
RewriteRule ^Resourc$ http://www.mosaic-industries.com/Resources/ [R=301,L,NC]
RewriteRule ^resources/\..*$ http://www.mosaic-industries.com/Resources/ [R=301,L]
RewriteRule ^Resources/\.\.\./mi-.*$ http://www.mosaic-industries.com/Resources/ [R=301,L]
RewriteRule ^scientific-instrumentation\.html$ http://www.mosaic-industries.com/instrument-control.html [R=301,L,NC]
RewriteRule ^sensor-calibration$ http://www.mosaic-industries.com/sensor-calibration.html [R=301,L,NC]
RewriteRule ^tutorial$ http://www.mosaic-industries.com/embedded-systems/microcontroller [R=301,L,NC]
RewriteRule ^wiki$ http://www.mosaic-industries.com/embedded-systems [R=301,L,NC]
RewriteRule ^wiki/.*$ http://www.mosaic-industries.com/embedded-systems [R=301,L,NC]
RewriteRule ^embedded-systems=$ http://www.mosaic-industries.com/embedded-systems [R=301,L,NC]
RewriteRule ^%20embedded-systems/instrumentation/conductivity-meter/microfabricated-planar-interdigitatedelectrodes-cell-constant$ http://www.mosaic-industries.com/embedded-systems/instrumentation/conductivity-meter/microfabricated-planar-interdigitated-electrodes-cell-constant [R=301,L,NC]
RewriteRule ^embedded-systems/instrumentation/conductivity-meter/microfabricated-planar-interdigitatedelectrodes-cell-constant$ http://www.mosaic-industries.com/embedded-systems/instrumentation/conductivity-meter/microfabricated-planar-interdigitated-electrodes-cell-constant [R=301,L,NC]
RewriteRule ^embedded/pdfs//embedded-linux-primer.pdf$ http://www.mosaic-industries.com/embedded-systems/pdfs/articles#embedded-linux-primera-practical-real-world-approach [R=301,L,NC]
RewriteRule ^embedded/cc-programming/$ http://www.mosaic-industries.com/embedded-systems/c-ide-software-development/learning-c-programming-language/microcontroller [R=301,L,NC]
RewriteRule ^paneltouchcontroller.html$ http://www.mosaic-industries.com/Products/SBC/PDQB.html [R=301,L,NC]
RewriteRule ^instrument-front-panel.html$ http://www.mosaic-industries.com/embedded-systems/sbc-single-board-computers/freescale-hcs12-9s12-c-language/microcontroller [R=301,L,NC]
RewriteRule ^raspberry-pi/gpio-pin-electrical-specifications$ http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/gpio-pin-electrical-specifications [R=301,L,NC]

## We do not have subdirectories for serving out a mobile site, so we redirect any requests for /m/ and /mobile/ domains to our standard site.
RewriteRule ^m/(.*)$ http://www.mosaic-industries.com/$1 [R=301,L,NC]
RewriteRule ^mobile/(.*)$ http://www.mosaic-industries.com/$1 [R=301,L,NC]
