<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Perishable Press</title>
	
	<link>http://perishablepress.com</link>
	<description>WordPress, Web Design, Code &amp; Tutorials</description>
	<lastBuildDate>Thu, 24 May 2012 18:41:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<feedburner:info uri="perishablepress" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><meta xmlns="http://pipes.yahoo.com" name="pipes" content="noprocess" /><image><link>http://perishablepress.com/</link><url>http://feeds.feedburner.com/~fc/perishablepress?bg=cccccc</url><title>Perishable Press</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://perishablepress.com/feed/" /><feedburner:emailServiceId>perishablepress</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://perishablepress.com/feed/" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Fperishablepress.com%2Ffeed%2F" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><feedburner:browserFriendly>Perishable Press provides high-quality, in-depth articles on web design and development, graphic design, social media, blogging, software, and more. Learn how to use WordPress, PHP, SQL, HTAccess, JavaScript, (X)HTML, and CSS to create beautiful sites that are usable, accessible, and secure.</feedburner:browserFriendly><item>
		<title>15+ Collections of Minimalist Web Design</title>
		<link>http://perishablepress.com/minimalist-web-design-examples/</link>
		<comments>http://perishablepress.com/minimalist-web-design-examples/#comments</comments>
		<pubDate>Wed, 23 May 2012 19:48:20 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[minimalism]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14878</guid>
		<description><![CDATA[I always enjoy looking at good minimalist web design. Here are my 15+ favorite collections of articles featuring minimalist design, comprising nearly 650 examples: Colorburned &#8212; 32 Amazing Minimalist Website Layouts DesignFestival &#8212; Top Minimalist Website Designs: Trends and 23 Examples Desizn Tech &#8212; Why minimal web design works? 6 Examples and analysis Hongkiat &#8212; 100+ Clean, Simple And Minimalist Website Designs Line25 &#8212; 50 Inspiring Examples of Minimalism in Web Design Six Revisions &#8212; 40 Beautiful [...]]]></description>
			<content:encoded><![CDATA[<p>I always enjoy looking at good minimalist web design. Here are my 15+ favorite collections of articles featuring minimalist design, comprising nearly <strong>650 examples</strong>:</p>
<p><span id="more-14878"></span></p>
<ol>
<li><strong>Colorburned</strong> &mdash; <a href="http://colorburned.com/32-amazing-minimalist-website-layouts/">32 Amazing Minimalist Website Layouts</a></li>
<li><strong>DesignFestival</strong> &mdash; <a href="http://designfestival.com/top-minimalist-website-designs-trends-and-examples/">Top Minimalist Website Designs: Trends and 23 Examples</a></li>
<li><strong>Desizn Tech</strong> &mdash; <a href="http://desizntech.info/2012/04/why-minimal-web-design-works-examples-and-analysis/">Why minimal web design works? 6 Examples and analysis</a></li>
<li><strong>Hongkiat</strong> &mdash; <a href="http://www.hongkiat.com/blog/clean-simple-minimalist-website-design/">100+ Clean, Simple And Minimalist Website Designs</a></li>
<li><strong>Line25</strong> &mdash; <a href="http://line25.com/articles/50-inspiring-examples-of-minimalism-in-web-design">50 Inspiring Examples of Minimalism in Web Design</a></li>
<li><strong>Six Revisions</strong> &mdash; <a href="http://sixrevisions.com/design-showcase-inspiration/40-beautiful-examples-of-minimalism-in-web-design/">40 Beautiful Examples of Minimalism in Web Design</a></li>
<li><strong>Six Revisions</strong> &mdash; <a href="http://sixrevisions.com/design-showcase-inspiration/30-beautiful-clean-and-simple-web-designs-for-inspiration/">30 Beautiful Clean and Simple Web Designs for Inspiration</a></li>
<li><strong>Smashing Magazine</strong> &mdash; <a href="http://www.smashingmagazine.com/2008/11/17/showcase-of-minimalist-and-clean-designs/">Showcase Of Clean And Minimalist Designs (40+ examples)</a></li>
<li><strong>Smashing Magazine</strong> &mdash; <a href="http://www.smashingmagazine.com/2010/05/13/principles-of-minimalist-web-design-with-examples/">Principles Of Minimalist Web Design, With 80+ Examples</a></li>
<li><strong>Speckyboy</strong> &mdash; <a href="http://speckyboy.com/2012/04/15/20-new-and-free-minimal-wordpress-themes/">20 New and Free Minimal WordPress Themes</a></li>
<li><strong>Speckyboy</strong> &mdash; <a href="http://speckyboy.com/2011/08/28/35-effective-examples-of-minimalism-in-web-design/">35 Effective Examples of Minimalism in Web Design</a></li>
<li><strong>Splashnology</strong> &mdash; <a href="http://www.splashnology.com/article/35-examples-of-minimalism-in-modern-web-design/4646/">35 Examples of Minimalism in Modern Web Design</a></li>
<li><strong>SpyreStudios</strong> &mdash; <a href="http://spyrestudios.com/showcase-of-20-minimalist-grid-based-web-designs/">Showcase of 20 Minimalist Grid-Based Web Designs</a></li>
<li><strong>SpyreStudios</strong> &mdash; <a href="http://spyrestudios.com/light-clean-designs-using-minimalist-color-scheme/">56 Light &#038; Clean Website Designs Using A Minimalist Color Scheme</a></li>
<li><strong>Tripwire Magazine</strong> &mdash; <a href="http://www.tripwiremagazine.com/2012/05/responsive-wordpress-themes.html">50 Best Responsive WordPress Themes</a></li>
<li><strong>Web Design Ledger</strong> &mdash; <a href="http://webdesignledger.com/inspiration/25-fresh-examples-of-minimalist-web-designs">25 Fresh Examples of Minimalist Web Designs</a></li>
</ol>
<p>That should get you going, let me know if you know of any that should be added to the list :)</p>
<p><!--authenticate--></p>
<p>Related posts:</p><ol>
<li><a href='http://perishablepress.com/series-summary-minimalist-web-design-showcase/' rel='bookmark' title='Series Summary: Minimalist Web Design Showcase'>Series Summary: Minimalist Web Design Showcase</a></li>
<li><a href='http://perishablepress.com/minimalist-web-design-showcase-equivocality/' rel='bookmark' title='Minimalist Web Design Showcase: Equivocality'>Minimalist Web Design Showcase: Equivocality</a></li>
<li><a href='http://perishablepress.com/minimalist-web-design-showcase-shauninmancom/' rel='bookmark' title='Minimalist Web Design Showcase: ShaunInman.com'>Minimalist Web Design Showcase: ShaunInman.com</a></li>
</ol><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8xa8k5J8Ls:IaeplUvLhqo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8xa8k5J8Ls:IaeplUvLhqo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8xa8k5J8Ls:IaeplUvLhqo:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8xa8k5J8Ls:IaeplUvLhqo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=g8xa8k5J8Ls:IaeplUvLhqo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=g8xa8k5J8Ls:IaeplUvLhqo:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/minimalist-web-design-examples/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>6G Beta</title>
		<link>http://perishablepress.com/6g-beta/</link>
		<comments>http://perishablepress.com/6g-beta/#comments</comments>
		<pubDate>Mon, 21 May 2012 17:43:02 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14840</guid>
		<description><![CDATA[Since releasing the 5G Blacklist earlier this year, malicious server scans and bad requests have surged with more novel attacks than I&#8217;ve seen since first getting into this stuff six years ago. In other words, now is the time to beef up security and lock things down. If you&#8217;re into monitoring your server and knowing your traffic, you may be observing the same recent spike in malicious activity. In response to these attacks, I&#8217;ve been secretly working [...]]]></description>
			<content:encoded><![CDATA[<p><img class="l" src="http://perishablepress.com/wp/wp-content/images/2012/6G-Blacklist.gif" alt="[ 6G Blacklist (beta) ]" /> Since releasing the <a href="http://perishablepress.com/5g-blacklist-2012/">5G Blacklist</a> earlier this year, malicious server scans and bad requests have <em>surged</em> with more novel attacks than I&#8217;ve seen since first getting into this stuff six years ago. In other words, <em>now</em> is the time to <strong>beef up security</strong> and <strong>lock things down</strong>. If you&#8217;re into <em>monitoring your server</em> and <em>knowing your traffic</em>, you may be observing the same recent spike in malicious activity. In response to these attacks, I&#8217;ve been secretly working on the next generation of <a href="http://perishablepress.com/tag/blacklist/" title="Posts I've written on blocking bad bots and securing your site using firewalls and blacklists">G-series blacklist</a>, the inevitable <strong>6G</strong> Firewall.</p>
<p><span id="more-14840"></span></p>
<p>Featured in this jam-packed post:</p>
<ul>
<li><a href="#blacklist" class="anchor"><strong>The 6G Firewall</strong> &#8211; beta version</a></li>
<li><a href="#development" class="anchor">Development strategy (building the 6G)</a>
<ul>
<li><a href="#request-strings" class="anchor">Front Line: Request strings</a></li>
<li><a href="#query-strings" class="anchor">Filtering Query strings</a></li>
<li><a href="#user-agents" class="anchor">Blocking Bad User-agents</a></li>
<li><a href="#referrers" class="anchor">Blocking Bad Referrers</a></li>
<li><a href="#block-ips" class="anchor">Blocking Bad IPs</a></li>
<li><a href="#ip-backlist" class="anchor">2012 IP Blacklist</a></li>
</ul>
</li>
<li><a href="#resources" class="anchor">Additional resources (article series)</a></li>
<li><a href="#thank-you" class="anchor">Credits and Thanks</a></li>
<li><a href="#important" class="anchor">Important notes..</a> <small>(read first!)</small></li>
</ul>
<p>Before getting started, take a moment to read thru the <a href="#important" class="anchor">important notes</a>, which contain information about using blacklists, server requirements, licensing, and other details. Then after presenting the 6G beta, we&#8217;ll jog through some of the thinking and strategy going into the code. Even without trying the blacklist, reading through &#8220;building the 6G Blacklist&#8221; should prove a beneficial exercise in pattern-matching and protecting against malicious <abbr title="Hypertext Transfer Protocol">HTTP</abbr> behavior.</p>
<h3 id="blacklist">6G Blacklist beta</h3>
<p>The 6G consists of the following sections:</p>
<ul>
<li><code># 6G:[REQUEST STRINGS]</code></li>
<li><code># 6G:[QUERY STRINGS]</code></li>
<li><code># 6G:[USER AGENTS]</code></li>
<li><code># 6G:[REFERRERS]</code></li>
<li><code># 6G:[BAD IPS]</code></li>
</ul>
<p>Each of these sections works independently of the others, such that you could, say, omit the entire query-string and IP-address blocks and the remaining sections would continue to work just fine. Mix-n-match to suit your needs. This code is formatted for deployment in your site&#8217;s <em>root</em> <code>.htaccess</code> file.</p>
<pre><code># 6G BLACKLIST/FIREWALL (beta)
# @ http://perishablepress.com/6g-beta/

# 6G:[REQUEST STRINGS]
&lt;ifModule mod_alias.c&gt;
 RedirectMatch 403 /(\$|\*)/?$
 RedirectMatch 403 (?i)(&lt;|&gt;|:|;|\'|\s)
 RedirectMatch 403 (?i)([a-zA-Z0-9]{18})
 RedirectMatch 403 (?i)(https?|ftp|php)\:/
 RedirectMatch 403 (?i)(\"|\.|\_|\&amp;|\&amp;amp)$
 RedirectMatch 403 (?i)(\=\\\'|\=\\%27|/\\\'/?)\.
 RedirectMatch 403 (?i)/(author\-panel|submit\-articles)/?$
 RedirectMatch 403 (?i)/(([0-9]{5})|([0-9]{6}))\-([0-9]{10})\.(gif|jpg|png)
 RedirectMatch 403 (?i)(\,|//|\)\+|/\,/|\{0\}|\(/\(|\.\.|\+\+\+|\||\\\"\\\")
 RedirectMatch 403 (?i)/uploads/([0-9]+)/([0-9]+)/(cache|cached|wp-opt|wp-supercache)\.php
 RedirectMatch 403 (?i)\.(asp|bash|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rar|rdf|well)
 RedirectMatch 403 (?i)/(^$|1|addlink|btn_hover|contact?|dkscsearch|dompdf|easyboard|ezooms|formvars|fotter|fpw|i|imagemanager|index1|install|iprober|legacy\-comments|join|js\-scraper|mapcms|mobiquo|phpinfo|phpspy|pingserver|playing|postgres|product|register|scraper|shell|signup|single\-default|t|sqlpatch|test|textboxes.css|thumb|timthumb|topper|tz|ucp_profile|visit|webring.docs|webshell|wp\-lenks|wp\-links|wp\-plugin|wp\-signup|wpcima|zboard|zzr)\.php
 RedirectMatch 403 (?i)/(\=|\$\&amp;|\_mm|administrator|auth|bytest|cachedyou|cgi\-|cvs|config\.|crossdomain\.xml|dbscripts|e107|etc/passwd|function\.array\-rand|function\.parse\-url|livecalendar|localhost|makefile|muieblackcat|release\-notes|rnd|sitecore|tapatalk|wwwroot)
 RedirectMatch 403 (?i)(\$\(this\)\.attr|\&amp;pws\=0|\&amp;t\=|\&amp;title\=|\%7BshopURL\%7Dimages|\_vti\_|\(null\)|$itemURL|ask/data/ask|com\_crop|document\)\.ready\(fu|echo.*kae|eval\(|fckeditor\.htm|function.parse|function\(\)|gifamp|hilton.ch|index.php\&amp;amp\;quot|jfbswww|monstermmorpg|msnbot\.htm|netdefender/hui|phpMyAdmin/config|proc/self|skin/zero_vote|/spaw2?|text/javascript|this.options)
&lt;/ifModule&gt;

# 6G:[QUERY STRINGS]
&lt;IfModule mod_rewrite.c&gt;
 RewriteCond %{REQUEST_URI} !^/$ [NC]
 RewriteCond %{QUERY_STRING} (mod|path|tag)= [NC,OR]
 RewriteCond %{QUERY_STRING} ([a-zA-Z0-9]{32}) [NC,OR]
 RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
 RewriteCond %{QUERY_STRING} (\?|\.\./|\.|\*|:|;|&lt;|&gt;|'|"|\)|\[|\]|=\\\'$|%0A|%0D|%22|%27|%3C|%3E|%00|%2e%2e) [NC,OR]
 RewriteCond %{QUERY_STRING} (benchmark|boot.ini|cast|declare|drop|echo.*kae|environ|etc/passwd|execute|input_file|insert|md5|mosconfig|scanner|select|set|union|update) [NC]
 RewriteRule .* - [F,L]
&lt;/IfModule&gt;

# 6G:[USER AGENTS]
&lt;ifModule mod_setenvif.c&gt;
 #SetEnvIfNoCase User-Agent ^$ keep_out
 SetEnvIfNoCase User-Agent (&lt;|&gt;|'|&amp;lt;|%0A|%0D|%27|%3C|%3E|%00|href\s) keep_out
 SetEnvIfNoCase User-Agent (archiver|binlar|casper|checkprivacy|clshttp|cmsworldmap|comodo|curl|diavol|dotbot|email|extract|feedfinder|flicky|grab|harvest|httrack|ia_archiver|jakarta|kmccrew|libwww|loader|miner|nikto|nutch|planetwork|purebot|pycurl|python|scan|skygrid|sucker|turnit|vikspider|wget|winhttp|youda|zmeu|zune) keep_out
 &lt;limit GET POST PUT&gt;
  Order Allow,Deny
  Allow from all
  Deny from env=keep_out
 &lt;/limit&gt;
&lt;/ifModule&gt;

# 6G:[REFERRERS]
&lt;IfModule mod_rewrite.c&gt;
 RewriteCond %{HTTP_REFERER} (&lt;|&gt;|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
 RewriteCond %{HTTP_REFERER} ([a-zA-Z0-9]{32}) [NC]
 RewriteRule .* - [F,L]
&lt;/IfModule&gt;

# 6G:[BAD IPS]
&lt;Limit GET POST PUT&gt;
 Order Allow,Deny
 Allow from all
 # uncomment/edit/repeat next line to block IPs
 # Deny from 123.456.789
&lt;/Limit&gt;</code></pre>
<p>Whoop, there it is, but <em>only for testing</em> at this point. So let me know in the comments or <a href="http://perishablepress.com/contact/">via email</a> with any discoveries on 6G beta. I&#8217;ll give it at least a month or so before rolling out the official release of the 6G. This beta version is admittedly heavy-handed in some areas, so plenty of edits are expected in the process of fine-tuning and dialing it in. Your help in this process is HUGE and appreciated by myself and other 6G users.</p>
<p>Alright, that&#8217;s that. New beta version, but how does it work? Let&#8217;s continue with some of the thinking and strategy going into the 6G Firewall..</p>
<h3 id="development">Behind the scenes / development strategy</h3>
<p>Filtering URL requests with Apache involves various modules and directives:</p>
<ul id="apache-modules">
<li><code># 6G:[REQUEST STRINGS] -&gt; </code> <a href="http://httpd.apache.org/docs/2.0/mod/mod_alias.html">mod_alias</a> (<code>RedirectMatch</code>)</li>
<li><code># 6G:[QUERY STRINGS] -&gt; </code> <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a> (<code>RewriteCond/RewriteRule</code>)</li>
<li><code># 6G:[USER AGENTS] -&gt; </code> <a href="http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html">mod_setenvif</a> (<code>SetEnvIfNoCase User-Agent</code>)</li>
<li><code># 6G:[REFERRERS] -&gt; </code> <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">mod_rewrite</a> (<code>RewriteCond/RewriteRule</code>)</li>
<li><code># 6G:[BAD IPS] -&gt; </code> <a href="http://httpd.apache.org/docs/current/mod/core.html#limit">core functionality via Limit</a> (<code>Order Allow,Deny</code>)</li>
</ul>
<p>These modules enable us to filter different parts of the request, such as the user-agent, referrer, and request-string. They operate both autonomously and cumulatively, providing much control over specific <abbr title="Hypertext Transfer Protocol">HTTP</abbr> activity and server traffic in general. Apache gives us <a href="http://perishablepress.com/eight-ways-to-blacklist-with-apaches-mod_rewrite/" title="Eight Ways to Blacklist with Apache's mod_rewrite">numerous ways to blacklist bad requests</a> and <a href="http://wptest.means.us.com/2012/05/web-site-security-blocking-user-agents-requests-query-strings/" title="Blocking bad user agents, requests &amp; queries to prevent hacking">block bad user agents, requests &amp; queries to prevent hacking</a>. To better understand how the <strong>6G Firewall</strong> works, let&#8217;s &#8220;zoom-in&#8221; on the different modules &amp; directives and examine some concrete examples..</p>
<h4 id="request-strings">Front Line: Request strings</h4>
<p>Apache&#8217;s <code>mod_alias</code> module enables our frontline of defense via the <code>RedirectMatch</code> directive. <abbr title="RedirectMatch">RM</abbr> is used to filter the actual base part of the URL that is requested on the server. Here are some examples of the types of nasty URL requests that are easily blocked via <code>mod_alias</code>/<abbr title="RedirectMatch">RM</abbr>:</p>
<pre><code>http://example.com/wp-content/themes/mimboedited/timthumb.php
http://example.com/themes/SimplePress/timthumb.php?src=http%3a%2f
http://example.com/plugins/auto-attachments/timthumb.php?src=http%3A%2F%2Fpicasa.com.ipsupply.com.au%2Fwp-http://example.com/content%2Fuploads%2F2012%2F03%2FIN.php
http://example.com/timthumb.php?src=http%3a%2f
http://example.com/timthumb.php?src=http%3A%2F%2Fflickr.com.bpmohio.com%2Fbad.php
http://example.com/timthumb/timthumb.php?src=http%3A%2F%2Fflickr.com.bpmohio.com%2Fbad.php
http://example.com/timthumb.php?src=http%3A%2F
http://example.com/themes/coda/timtumb.php?src=
http://example.com/timthumb.php?src=http%3A%2F%2Fpicasa.com.ipsupply.com.au%2Fwp-content%2Fuploads%2F2012%2F03%2FIN.php
http://example.com/timthumb.phptimthumb.php?src=
http://example.com/timthumb.phptimthumb.php?src=

http://example.com/wp-content/themes/chapters/thumb.php?src=http%3a%2f%2fpicasa.combos.orgasmguide.org/tmp.php
http://example.com/wp-content/themes/chapters/thumb.php?src=http%3a%2f%2fpicasa.combos.orgasmguide.org/byroe.php</code></pre>
<p>This is a great example as it shows varieties of possibly the most-scanned-for target ever: <code>timthumb.php</code> and its numerous incarnations. Malicious scanners also frequently target files named <code>thumb.php</code> and similar. Recursive scans can mean <em>hundreds or thousands</em> of requests hitting your server in short periods of time. This <strong>drains resources</strong> and negatively impacts site performance. As if that&#8217;s not reason enough to block such activity, if the target vulnerability is actually found on your server, it&#8217;s &#8220;game over&#8221;. So the 6G protects by blocking requests for both <code>thumb.php</code> and <code>timthumb.php</code>, using logic similar to this:</p>
<p><code>RedirectMatch 403 (?i)/(thumb|timthumb)\.php</code></p>
<p>That <em>one line</em> in your <a href="http://perishablepress.com/category/web-design/htaccess/" title="Learn more about .htaccess">.htaccess</a> file will block all URL requests that include either <code>thumb.php</code> and <code>timthumb.php</code> (not including the query string). This helps keep <em>many</em> malicious requests at bay, freeing up valuable resources for <em>legit</em> requests. Note that if you are timthumb or similar &#8220;thumb&#8221; script for your site, you will need to remove the <code>thumb|timthumb|</code> string from 6G (<code>REQUEST STRINGS</code> section).</p>
<p>The first &#8220;REQUEST-STRINGS&#8221; section in the 6G uses this strategy to block many different types of malicious requests. With each generation of the 6G, the various rules and patterns are further refined and updated to block the most dangerous and relevant types of requests. Pattern-matching with regular expressions enables us to block many different types of threats; however, as precise as we can get, there remain commonly scanned-for targets that are simply too common or too general to block effectively. Consider the following examples:</p>
<pre><code>http://example.com/[path]/share
http://example.com/[path]]/login
http://example.com/[path]/signin
http://example.com/[path]/accepted
http://example.com/[path]/feed.php
http://example.com/[path]/form.php
http://example.com/[path]/format.php
http://example.com/[path]/plugin-editor.php
http://example.com/[path]/post.php
http://example.com/[path]/post-new.php
http://example.com/[path]/wp-comments-post.php
http://example.com/[path]/wp-conf.php
http://example.com/[path]/wp-error.php
http://example.com/[path]/wp-library.php
http://example.com/[path]/wp-post.php
http://example.com/[path]/update.php
http://example.com/[path]/upload.php</code></pre>
<p>In these examples URLs, the target string is the part appearing immediately after the &ldquo;<code>http://example.com/[path]/</code>&rdquo;, which is necessary to include in this post because it prevents sloppy search engines and bad bots from following these supposedly &#8220;relative&#8221; links and generating further 404 errors. But I digress.. the point here is that malicious scans frequently target existing files that are too common to block in a widely distributed firewall such as 6G. If you&#8217;re getting hit with many requests for common/well-known files, my best advice is to custom-craft a few rules based on the actual structure and content of your site.</p>
<p>A quick example of this, let&#8217;s say the server is getting hammered by malicious requests targeting a file named <code>post-new.php</code>. This file name is common enough to warrant <em>not</em> blacklisting in the 6G, even though it is trivial to block on an individual basis. Here at <a href="http://perishablepress.com/">Perishable Press</a>, I&#8217;m <strong>running WordPress in a subdirectory</strong> named &ldquo;<code>/wp/</code>&rdquo;, so I know <em>immediately</em> that I can safely block all requests for <code>post.php</code> that <em>aren&#8217;t</em> located in the <code>/wp/</code> directory.</p>
<pre><code>RewriteCond %{REQUEST_URI} !^/wp/wp-admin/post.php [NC]
RewriteCond %{REQUEST_URI} /post.php [NC]
RewriteRule .* - [F,L]</code></pre>
<p>Similarly, as the <code>post.php</code> file is located in a subdirectory and not root, we can use <code>mod_alias</code>&rsquo; <code>RedirectMatch</code> to block all requests for the file in a root-install of WordPress:</p>
<p><code>RedirectMatch 403 ^/wp-admin/post.php</code></p>
<p>With either of these methods, other common files are easily added to the rule, safely eliminating extraneous requests for non-existent files. This example serves to demonstrate one of the shortcomings of any copy/paste blacklist, while illustrating the importance of customizing and fine-tuning your own security strategy.</p>
<h4 id="query-strings">Filtering Query strings</h4>
<p>Some URLs include a <strong>query-string</strong>, which is appended to the URL via question mark (<code>?</code>). Query strings tend to look like gibberish or random strings to the uninitiated, but are actually highly specific, well-structured data used to communicate between browser and server. Without knowing what&#8217;s happening on your server, it may difficult to discern between good and bad query-string requests, but there are some things to look for:</p>
<ul>
<li>Unusual and/or unexpected characters such as additional question marks, angled brackets, asterix, and so on</li>
<li>Unencoded characters that should be encoded, such as these: <code>$ &amp; + , / : ; = ? @</code></li>
<li>Super-long random-looking strings of encoded gibberish, alphanumeric or laced with symbols such as <code>%</code></li>
<li>Super-short query strings that may seem to terminate abruptly, often with a single quote (<code>'</code>), double quote (<code>"</code>), or equal sign (<code>=</code>)</li>
</ul>
<p>There are other signs as well, but ultimately it comes down to whether the request is understood or not by the server. If it&#8217;s not, the request could be a simple 404 error or similar, or it could be malicious. Generally the one-off 404s are the result of typos or other human errors, and tend to appear sporadically or infrequently in the server-access logs. Contrast this with <em>malicious</em> query-string requests that occur frequently, in rapid succession, targeting non-existent files with encoded gibberish and other nonsense.</p>
<p>With the <a href="http://perishablepress.com/5g-blacklist-2012/">5G Blacklist</a> in place, many evil query-string requests are blocked, but with the recent surge of scanning activity, a <em>new breed</em> of encoded nasty was getting through, looking similar to these examples:</p>
<pre><code>?aHR0cDovL3BlcmlzaGFibGVwcmVzcy5jb20vY3NzLWltYWdlLWNhY2hpbmcv==
?aHR0cDovL3BlcmlzaGFibGVwcmVzcy5jb20vaHRtbDUtdGFibGUtdGVtcGxhdGUv==
?aHR0cDovL3BlcmlzaGFibGVwcmVzcy5jb20vYmFzaWMtZG9zLWNvbW1hbmRzLw==
?aHR0cDovL3BlcmlzaGFibGVwcmVzcy5jb20vd2hhdC1pcy1teS13b3JkcHJlc3MtZmVlZC11cmwv
?aHR0cDovL3BlcmlzaGFibGVwcmVzcy5jb20vcHJlc3MvMjAwNy8wMS8xNi9tYXhpbXVtLWFuZC1taW5pbXVtLWhlaWdodC1hbmQtd2lkdGgtaW4taW50ZXJuZXQtZXhwbG9yZXIv
?actions=get_wp_version%2Cget_plugins%2Cget_themes%2Csupports_backups%2Cget_filesystem_method&amp;wpr_api_key=15644F32D7D80B3150710834D8F406E9&amp;t=1335026415
?actions=get_wp_version%2Cget_plugins%2Cget_themes%2Csupports_backups%2Cget_filesystem_method&amp;wpr_api_key=15644F32D7D80B3150710834D8F406E9&amp;t=1335026385</code></pre>
<p>As you can see, these malicious strings contain numerous common-denominators that could be matched against, such as:</p>
<ul>
<li><code>%2C</code> matching the <a href="http://perishablepress.com/tools/utf8-hex/">UTF-8 (hex) encoded</a> encoded comma (<code>,</code>) would be partially effective</li>
<li><code>==</code> matching two equal signs would be partially effective</li>
<li>Other character combinations..?</li>
</ul>
<p>We <em>could</em> match the hex-encoded comma, but that&#8217;s such a common character that it would cause more problems than it would solve (in most cases), so really not an option. Looking closely at other possible character-combinations, suddenly the &#8220;least-common denominator&#8221; hits you: long, random sequences of alphanumeric characters appear in all of these examples, and many others that I&#8217;ve encountered. Thus, in the query-string section of the 6G, excessively long strings of alphanumeric characters are effectively blocked with the following rule:</p>
<p><code>RewriteCond %{QUERY_STRING} ([a-zA-Z0-9]{32}) [NC,OR]</code></p>
<p>Yeah.. the trick here is choosing the optimal number of sequential characters to match against. If we set the match to, say, <code>{16}</code>, the number of <em>false positives</em> increases; conversely, if we set the match to a larger number, such as <code>{64}</code>, the number of <em>false negatives</em> increases. So once again it&#8217;s all about finding the balance.</p>
<p><strong>Important note</strong> about placement of the 6G query-string rules within the <code>.htaccess</code> file. If the query-string rules don&#8217;t seem to be working, try moving them to appear <em>before</em> any other <code>mod_rewrite</code> rules that may be in play. I&#8217;m not sure why this is the case, but I think it has something to do with the query-string data being unavailable for processing after the first encounter with <code>mod_rewrite</code>. Any info on this would be appreciated :)</p>
<h4 id="user-agents">Blocking Bad User-agents</h4>
<p>The next two sections in the 6G protect against some of the worst user-agents and referrers from messing with your site. The technique is essentially the same as with the request-string and query-string sections, but filters different properties of the <abbr title="Uniform Resource Idnetifier">URI</abbr> request. </p>
<p>The specified <strong>user-agent</strong> of a request may consist of multiple elements, and it may be empty. Previous versions of the g-series blacklist block empty (or &#8220;blank&#8221;) user-agents with the following rule:</p>
<p><code>SetEnvIfNoCase User-Agent ^$ keep_out</code></p>
<p>This rule &#8220;flags&#8221; any request from a blank user-agent, and worked well for many years. These days, however, social-media, mobile apps, PayPal, and certain Ajax requests frequently use an empty string as the user-agent when interacting with the server. For example, Google requires the blank user-agent in order to display thumbnails for Google+. So at this point the pros/cons of blocking bad empty requests is a no-brainer and the rule is now &#8220;deprecated&#8221; (commented-out) with a pound-sign (<code>#</code>).</p>
<p>Beyond this, the 6G USER-AGENTS section includes <em>new rules</em to block malicious character-strings operating via the user-agent string. The 5G blocks some of the "worst of the worst" known bad user-agents, stuff like:</p>
<ul>
<li><code>binlar</code></li>
<li><code>nutch</code></li>
<li><code>sucker</code></li>
<li><code>zmeu</code></li>
</ul>
<p>Plus around 20 other nasty agents are blocked in the 5G, with the entire &#8220;USER-AGENT&#8221; section included as sort of a template for individual customization. Unfortunately, there are increasing numbers of malicious strings being passed as the user-agent, so the 6G includes more protection in this area. The 6G not only blocks additional well-known bad agents, it protects against encoded strings, forbidden characters, and other malicious garbage. Most of this is accomplished with a single new directive:</p>
<p><code>SetEnvIfNoCase User-Agent (&lt;|&gt;|'|&amp;lt;|%0A|%0D|%27|%3C|%3E|%00|href\s) keep_out</code></p>
<p>These character strings have no business appearing in the user-agent string. Most if not all of the widely used browsers such as Firefox, Chrome, Opera, IE, mobile browsers, feed readers, and even borderline/questionable scripts and bots refrain from suing any of these forbidden characters in their user-agent description. For example, here is Chrome&#8217;s reported user-agent:</p>
<p><code>Mozilla/5.0 Macintosh Intel Mac OS X 10_6_8 AppleWebKit/536.5 KHTML, like Gecko Chrome/19.0.1084.46 Safari/536.5</code></p>
<p>Legitimate user-agents contain only <em>valid</em> strings, so blocking illegal characters is an effective way to filter directory-traversals, <abbr title="Cross-Site Scripting">XSS</abbr> attacks, and other malicious exploits.</p>
<h4 id="referrers">Blocking Bad Referrers</h4>
<p>The 6G Firewall/Blacklist also includes new directives for blocking bad referrers. The strategy here is similar to that of the additional QUERY-STRING rules: filtering malicious character-strings to protect against bad referrers. Referrer information isn&#8217;t always included with the request, so we don&#8217;t want to block blank referrers, but forbidden characters are safely blocked, as are long strings (32 characters or more) of strictly alphanumeric characters. A simple and effective strategy using the following two filters:</p>
<p><code>RewriteCond %{HTTP_REFERER} (&lt;|&gt;|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]</code><br />
<code>RewriteCond %{HTTP_REFERER} ([a-zA-Z0-9]{32}) [NC]</code></p>
<p>This also serves as a <em>template</em> for further customization. If you&#8217;re seeing lots of weird referrers filling your access/error logs, the REFERRERS section of the 6G will help to curb the riff-raff.</p>
<h4 id="block-ips">Blocking Bad IPs</h4>
<p>Blocking by IP address is best used for specific threats, either individual, or by region, country, or similar. With a strong firewall, blocking IPs is unnecessary <em>unless</em> someone or something is attacking you specifically with requests that aren&#8217;t being blocked. I&#8217;ve heard from a number of people saying that their sites are being targeted/harassed by weird stalkers, enemies, spurned lovers, and it goes on and on. I&#8217;ve experienced this through a chat/forum site that had attracted all sorts of low-life, bottom-feeding douche-bags. They would just jump into the chat at random and ruin the conversation with potty humor and juvenile slurs. The <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> blacklist for the chat script wasn&#8217;t catching a lot of the garbage, so it was a perfect time to check the logs and ban the fools individually. After a bit of research and a few lines of <code>.htaccess</code>, the idiots were gone and peace was restored to the chat forum.</p>
<p>Thus, for the purpose of blocking individual threats the &#8220;bad-IPs&#8221; section of the 6G is entirely optional and intended as a template to use should the need arise. By default, the bad-IPs section in the 6G is empty, but over the past few months I&#8217;ve assembled my own private collection of blacklisted IP addresses. These are the some of the <em>worst offenders</em> I&#8217;ve seen this year:</p>
<div id="ip-backlist"><strong># 2012 IP Blacklist</strong></div>
<pre><code> Deny from 24.213.139.114
 Deny from 87.144.218.222
 Deny from 95.5.32.79
 Deny from 213.251.186.27
 Deny from 88.191.93.186
 Deny from 91.121.136.44
 Deny from 50.56.92.47
 Deny from 174.143.148.105
 Deny from 82.170.168.91
 Deny from 24.213.139.114
 Deny from 61.147.110.14
 Deny from 188.134.42.65
 Deny from 122.164.215.155
 Deny from 65.49.68.173
 Deny from 220.155.1.166
 Deny from 218.38.16.26
 Deny from 50.56.92.47
 Deny from 24.213.139.114
 Deny from 91.200.19.84
 Deny from 31.44.199.131
 Deny from 49.50.8.63</code></pre>
<p>Including these IPs is entirely optional &mdash; they are provided here mostly for reference, but also for &uuml;ber-paranoid faction ;)</p>
<h3 id="resources">Further reading..</h3>
<p>For more information on blacklisting, regular-expressions, and <code>.htaccess</code> methods, here are some choice offerings from the archives:</p>
<ul>
<li><a href="http://perishablepress.com/series-summary-building-the-3g-blacklist/">Building the 3G Blacklist</a></li>
<li><a href="http://perishablepress.com/building-the-perishable-press-4g-blacklist/">Building the 4G Blacklist</a></li>
<li><a href="http://perishablepress.com/building-the-5g-blacklist/">Building the 5G Blacklist</a></li>
<li><a href="http://perishablepress.com/blank-space-whitespace-character-htaccess/">Blank-Space/Whitespace Character for .htaccess</a>
<li><a href="http://perishablepress.com/case-insensitive-redirectmatch/">Case-Insensitive RedirectMatch</a></li>
</ul>
<p>And of course, many more articles in the <a href="http://perishablepress.com/archives/">Perishable Press Archives</a>.</p>
<h3 id="thank-you">Thanks to..</h3>
<p><strong>Thank you</strong> to everyone who contributes to the g-series blacklist with feedback, suggestions, test-results, and <em>links</em>. Specifically for the 6G beta, huge thanks goes to <a href="http://the-web-mechanic.com/">Ken Dawes</a> and <a href="http://wptest.means.us.com/">Andy Wrigley</a> for their generous help.</p>
<h3 id="important">Important notes..</h3>
<p>This is the <strong>beta release</strong> of the <abbr title="6th Generation">6G</abbr> Blacklist. There have been many improvements, including optimized code, greater accuracy, and better overall protection. I&#8217;ve been running the 6G (in its various incarnation) here at <a href="http://perishablepress.com/" title="WordPress, Web Design, Code &amp; Tutorials">Perishable Press</a> for the past several weeks and have been well-pleased with the results. The <strong>6G</strong> is pretty slick stuff, but there are some important things to keep in mind:</p>
<dl>
<dt>It takes more than a blacklist to secure your site</dt>
<dd>No one single security measure is perfect; good security is the result of many concerted <em>strategic layers</em> of protection. The 6G is designed to better secure your site by adding a <strong>strong layer</strong> of protection. </dd>
<dt>Sometimes blacklists block legit requests</dt>
<dd>A perfect firewall would block only <em>bad</em> traffic, but in reality it&#8217;s <em>inevitable</em> that some good requests get blocked. The goal is to keep the number of <em>false positives to a minimum</em> while maximizing the effectiveness of the ruleset. It&#8217;s a statistical game of sorts.</dd>
<dt>Resolving issues..</dt>
<dd>If/when you do encounter a potential false positive (e.g., you can&#8217;t load a certain page), there is a simple way to determine if it&#8217;s that crazy chunk of blacklist code you stuck into your <code>.htaccess</code> file. If you remove the blacklist and the page in question begins to work, well, you&#8217;ve can either forget about it or take a few moments to locate the offending rule and remove it from the list. I&#8217;ve found that it&#8217;s better to &#8220;comment out&#8221; rather than delete as it&#8217;s easier to keep track of things when the inevitable next version of the blacklist hits the streets.</dd>
<dt>This is beta.</dt>
<dd>And most importantly, this is the <strong>beta version</strong> of the 6G. As mentioned, there&#8217;s a lot of new stuff happening with this blacklist, and it&#8217;s super-important for me to thoroughly test via widest base possible. Only use this code if you are savvy and want to help out by reporting data, errors, logs, or whatever. That said, this &#8220;beta&#8221; version has been running flawlessly on multiple sites, including one that&#8217;s super-complex with many themes, plugins, and customizations (i.e., this site).</dd>
<dt>It&#8217;s all you.</dt>
<dd>Once the code leaves this site, <strong>you</strong> assume all responsibility. Always back up your original working <code>.htaccess</code> file and you should be good to go.</dd>
<dt>Server requirements</dt>
<dd>Linux/Apache or similar (if adapted). 6G is formatted for deployment in <code>.htaccess</code> files, and also works when formatted for use directly in the Apache main configuration file. For the required Apache modules, see <a href="#apache-modules" class="anchor">this list</a>.</dd>
<dt>License</dt>
<dd><a href="https://www.gnu.org/licenses/gpl.html">GNU General Public License</a>.</dd>
</dl>
<p>I freely share my work on the g-series blacklist to help the community better protect their sites against malicious activity. If you find it useful, please show support by linking and sharing so others may learn and benefit as well. Thanks.</p>
<p><!--authenticate--></p>
<p>Related posts:</p><ol>
<li><a href='http://perishablepress.com/5g-firewall-beta/' rel='bookmark' title='5G Firewall Beta'>5G Firewall Beta</a></li>
<li><a href='http://perishablepress.com/case-insensitive-redirectmatch/' rel='bookmark' title='Case-Insensitive RedirectMatch'>Case-Insensitive RedirectMatch</a></li>
<li><a href='http://perishablepress.com/5g-blacklist-2012/' rel='bookmark' title='5G Blacklist 2012'>5G Blacklist 2012</a></li>
</ol><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=RQ9Hs6uAZZY:bxj4fIXVSIw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=RQ9Hs6uAZZY:bxj4fIXVSIw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=RQ9Hs6uAZZY:bxj4fIXVSIw:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=RQ9Hs6uAZZY:bxj4fIXVSIw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=RQ9Hs6uAZZY:bxj4fIXVSIw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=RQ9Hs6uAZZY:bxj4fIXVSIw:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/6g-beta/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Add Google+ Share Button to Any Site</title>
		<link>http://perishablepress.com/google-share-button/</link>
		<comments>http://perishablepress.com/google-share-button/#comments</comments>
		<pubDate>Wed, 02 May 2012 17:44:05 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[social-media]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14856</guid>
		<description><![CDATA[g+ Share button Word on the streets is that the new Google+ Share button is the best way yet to benefit from Google&#8217;s myriad social-media services and all-important search-engine. And Google makes it SO easy to add the new Share button to your website. This article explains what it is, where it fits in with all the other social-Google stuff, and of course how to add the g+ Share button to any site. What is Google Share? [...]]]></description>
			<content:encoded><![CDATA[<p><span class="capl"><img src="http://perishablepress.com/wp/wp-content/images/2012/google-share-button.jpg" alt="[ Google+ Share Button" /><br />g+ Share button</span> Word on the streets is that the new <strong>Google+ Share button</strong> is the best way yet to benefit from Google&#8217;s myriad social-media services and all-important search-engine. And Google makes it SO easy to add the new Share button to your website. This article explains what it is, where it fits in with all the other social-Google stuff, and of course <em>how</em> to add the <strong>g+ Share button</strong> to <em>any</em> site.</p>
<p><span id="more-14856"></span></p>
<h3>What is Google Share?</h3>
<p>If this was Google&#8217;s <em>only</em> social-media project, <a href="https://developers.google.com/+/plugins/share/" title="Google+ Share">Share</a> would be a no-brainer: it&#8217;s for <strong>sharing stuff on Google+</strong>. But it&#8217;s not. With the new Share button, there&#8217;s <strong>Google</strong>, <strong>iGoogle</strong>, <strong>Google+</strong>, <strong>Google+ +1</strong>, and now, <strong>Google+ Share</strong>. Huh? That&#8217;s a lot of plus signs and &#8220;ooh&#8221; sounds.. Whatever, here&#8217;s an overview/recap for the confused masses (approx chronological order):</p>
<ol>
<li><strong>Google</strong> bookmarking using your account profile</li>
<li><strong>iGoogle</strong> add links and content to your startpage</li>
<li><strong>Google+</strong> alternative to Facebook</li>
<li><strong>Google +1</strong> similar to Facebook&#8217;s &#8220;Like&#8221;, but for search results</li>
<li><strong>Google+</strong> Share makes it <em>really</em> easy to share stuff on Google+ (see #3)</li>
</ol>
<p>..and for the visually inclined:</p>
<p><img src="http://perishablepress.com/wp/wp-content/images/2012/google-share-button-02.jpg" alt="[ Google's social-media projects ]" /></p>
<p>What&#8217;s it all mean? Far from me to explain it all, but I can tell you honestly that I&#8217;ve paid little attention to any of Google&#8217;s social-media services <em>until now</em>. From what I can tell, for Google 5th time&#8217;s a charm &mdash; <strong>g+ Share</strong> brings one-click content sharing with the world&#8217;s most influential search engine. Plus the wizardz at Google have made it absolutely <strong>drop-dead easy</strong>. Sound good? Here&#8217;s how to set it up on your site in a matter of minutes..</p>
<h3>How to add the Google+ Share button to your site</h3>
<p>To get going with the <strong>g+ Share</strong> buttons, copy/paste the following code anywhere in your <abbr title="Hypertext Markup Language">HTML</abbr> file:</p>
<pre><code>&lt;script src="https://apis.google.com/js/plusone.js"&gt;&lt;/script&gt;
&lt;g:plus action="share" annotation="bubble"&gt;&lt;/g:plus&gt;</code></pre>
<p>Done. Visit your web page in a browser and you should see the Share button displayed like so:</p>
<p><img src="http://perishablepress.com/wp/wp-content/images/2012/google-share-button-01.jpg" alt="[ Example of Google+ Share button ]" /></p>
<p>That&#8217;s really all there is to it. Once you&#8217;ve got the Share button on your pages, visitors can quickly and easily share your content with their circles (public and/or private), friends, and just about anyone else using Google. When the visitor hovers over the button, a simple popup box displays this (if logged-in to their Google+ account):</p>
<p><img src="http://perishablepress.com/wp/wp-content/images/2012/google-share-button-03.jpg" alt="[ Share button popup on mouseover/hover (logged in) ]" /></p>
<p>..or, if the user is <em>not</em> logged in to any Google account, the popup will display a simple &#8220;Share this on Google+&#8221; message. If an unlogged user clicks the button, they are invited to sign up for a Google+ account. If the user is already logged in, clicking the Share button results in a popup box similar to this: </p>
<p><img src="http://perishablepress.com/wp/wp-content/images/2012/google-share-button-04.jpg" alt="[ popup after user clicks the Share button (logged in) ]" /></p>
<p>..and then Google does its thing and takes over from there. It&#8217;s <em>seductively</em> simple &mdash; something worth checking out <em>at least</em> once before loving it or moving on to the next. Typically I&#8217;m not a huge social-media buff, but this one&#8217;s fun, easy, and <em>worth it</em>. </p>
<h3>How to customize the Google+ Share button</h3>
<p>The previous &#8220;quick-n-dirty&#8221; method for adding the Share button is great to get things rolling, but eventually you may decide that some customization is in order. Using the official <a href="https://developers.google.com/+/plugins/share/">g+ Share dev page</a> with some help from <a href="https://developers.google.com/+/plugins/+1button/">+1 Button dev page</a>, here are some  examples showing how to customize and implement the Google+ Share button.</p>
<h4>Easy way for basic customizing</h4>
<p>For easy &amp; basic customizing, visit the <a href="https://developers.google.com/+/plugins/share/">g+ Share dev page</a> and play with the Share-button generator. Currently, you can only specify the <strong>Annotation</strong>, <strong>Size</strong>, and <strong>Language</strong>, but  it may be enough to get the job done.</p>
<h4>Asynchronous JavaScript loading</h4>
<p>This is the method I&#8217;m using here at <a href="http://perishablepress.com/">Perishable Press</a>, with the Share buttons displayed beneath the title on single posts only (see beneath the title of this post for an example).</p>
<pre><code>&lt;g:plus action="share" annotation="none"&gt;&lt;/g:plus&gt;
&lt;script type="text/javascript"&gt;
	(function() {
		var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
		po.src = 'https://apis.google.com/js/plusone.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
	})();
&lt;/script&gt;</code></pre>
<p>In addition to the asynchronous loading, this example also disables the &#8220;Share this on Google+&#8221; annotation to keep things super-simple. Here are some of the other tag attributes for the Share button:</p>
<ul>
<li><strong>href</strong> &mdash; URL to share (default = current page)</li>
<li><strong>annotation</strong> &mdash; inline, bubble, vertical-bubble, or none (default = bubble)</li>
<li><strong>width</strong> &mdash; maximum width for the button (no default)</li>
<li><strong>height</strong> &mdash; exact height of the button (default = 20)</li>
<li><strong>align</strong> &mdash; left or right (default: left)</li>
<li><strong>expandTo</strong> &mdash; top, right, bottom, left (default = empty list)</li>
<li><strong>onstartinteraction</strong> &mdash; function(jsonParam) (no default)</li>
<li><strong>onendinteraction</strong> &mdash; function(jsonParam (no default)</li>
</ul>
<p>For more info on this and other parameters and attributes, <a href="https://developers.google.com/+/plugins/share/">visit the Share dev page</a>.</p>
<h4>Add the Google+ Share button to WordPress</h4>
<p>With WordPress, adding the Share button works the same way: just add the code anywhere in your theme template files and done. If you only want to display the Share button on <em>single</em> posts (as mentioned previously), move the chunk of JavaScript code to the footer (just before the closing <code>&lt;/body&gt;</code> tag), and wrap it with a <abbr title="WordPress">WP</abbr> conditional tag:</p>
<pre><code>&lt;?php if(is_single()) { ?&gt;
&lt;!-- put the Share-button JavaScript here --&gt;
&lt;?php } ?&gt;</code></pre>
<p>WordPress <a href="http://codex.wordpress.org/Conditional_Tags" title="WP Codex">conditional tags</a> enable you to display the button just about any type of pageview &mdash; single-posts, archive views, pages, and more. Once the JavaScript is optimally configured, add the following code snippet wherever you would like to display the button:</p>
<p><code>&lt;g:plus action="share" annotation="none"&gt;&lt;/g:plus&gt;</code></p>
<p>And in case you were wondering about displaying <strong>multiple Share buttons</strong>, say, on your home page, go right ahead &mdash; should work just fine.</p>
<h4>How to style the Share button with CSS</h4>
<p>One minor annoyance I encountered while implementing the Share button is that it&#8217;s impossible to style the contents of an <code>&lt;iframe&gt;</code> with <abbr title="Cascading Style Sheets">CSS</abbr>. And that&#8217;s exactly how the Share button is displayed on your site &mdash; using a LOT of markup all rolled up into a convenient <code>&lt;iframe&gt;</code>. As an example, here&#8217;s the markup generated for the Share button on a <a href="http://perishablepress.com/blank-space-whitespace-character-htaccess/" title="Blank Space / Whitespace Character for .htaccess">recent post</a></p>
<pre><code>&lt;div id="___plus_0" 
     style="height: 20px; 
     display: inline-block; 
     text-indent: 0pt; 
     margin: 0pt; 
     padding: 0pt; 
     background: none repeat scroll 0% 0% transparent; 
     border-style: none; 
     float: none; 
     line-height: normal; 
     font-size: 1px; 
     vertical-align: baseline; 
     width: 59px;"&gt;

	&lt;iframe width="100%" 
		scrolling="no" 
		frameborder="0" 
		src="https://plusone.google.com/_/+1/sharebutton?plusShare=true&amp;amp;url=http%3A%2F%2Fperishablepress.com%2Fblank-space-whitespace-character-htaccess%2F&amp;amp;size=badge&amp;amp;height=20&amp;amp;action=share&amp;amp;annotation=none&amp;amp;hl=en-US&amp;amp;jsh=m%3B%2F_%2Fapps-static%2F_%2Fjs%2Fgapi%2F__features__%2Frt%3Dj%2Fver%3DqSmw0ZimOMA.en.%2Fsv%3D1%2Fam%3D!ZYKB1uRfgCaIKcjORg%2Fd%3D1%2Frs%3DAItRSTNFI795jiXRZoeKYjOooBGIFuZw-g#id=I1_1335943291567&amp;amp;parent=http%3A%2F%2Fperishablepress.com&amp;amp;rpctoken=123318742&amp;amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart" 
		name="I1_1335943291567" 
		id="I1_1335943291567" 
		vspace="0" 
		tabindex="0" 
		style="position: static; 
		       top: 0pt; 
		       width: 59px; 
		       margin: 0px; 
		       border-style: none; 
		       height: 20px; 
		       left: 0pt; 
		       visibility: visible;" 
		marginwidth="0" 
		marginheight="0" 
		hspace="0" 
		allowtransparency="true" 
		title="+Share"/&gt;
&lt;/div&gt;</code></pre>
<p>That&#8217;s a big chunk, containing lots of inline styles on both the inline frame and the parent <code>&lt;div&gt;</code> container. It&#8217;s also relatively &#8220;hookless&#8221; &mdash; no obvious classes for CSS styling, not to mention it can be difficult to override inline styles and next to impossible to style the contents of the <code>&lt;iframe&gt;</code>, which involves <em>even more</em> code that we won&#8217;t get into here. But if you&#8217;re savvy with your browser, there are ways (e.g., Firebug) of getting in there and inspecting things in <em>excruciating</em> detail.</p>
<p>The easiest modular approach that I could muster is simply wrapping the Share tag/element with a parent <code>&lt;div class="gplus"&gt;</code> (block-level) or <code>&lt;span class="gplus"&gt;</code> (inline), and then style with CSS as needed (or as much as possible). Here is an example:</p>
<p><code>&lt;span class="gplus"&gt;&lt;g:plus action="share" annotation="none"&gt;&lt;/g:plus&gt;&lt;/span&gt;</code></p>
<p>So virtually <em>nil</em> control over the actual Share button, but the parent <code>.gplus</code> makes it easy to tweak the location of the button with something like this:</p>
<p><code>.gplus { position: relative; top: 5px; }</code></p>
<p>The <code>.gplus</code> (or whatever) hook makes it easier to fine-tune position, background color, additional borders, or whatever gels with the design.</p>
<h3>Notes &amp; stuff</h3>
<p>Some potentially useful bits when working with Share buttons..</p>
<ul>
<li><strong>How is the share URL determined?</strong> &mdash; 1) explicit <code>href</code> attribute on share tag, 2) <code>&lt;link rel="canonical" href="http://www.example.com"&gt;</code>, or 3) <code>document.location.href</code></li>
<li><strong>Placement of the JavaScript/share-tag?</strong> &mdash; the JavaScript is recommended placed directly after the share tag (markup), but it may be placed anywhere on the page (footer, header, body).</li>
</ul>
<p>I also noticed that pages containing the Share button seemed to reload the page occasionally as I was testing things and logging in and out of my Google+ account. It looks like this behavior helps determine the contents of the popup/modal window. Not sure how that works without looking into it, so if anyone knows more about that, shout it out. For more of the &#8220;details&#8221; involved with Share, check the <a href="https://developers.google.com/+/plugins/share/#faqs">FAQs</a>.</p>
<p><strong>Update</strong> (2012/05/04): Looking closer at the differences between Share and +1 buttons:</p>
<ul>
<li><strong>Share</strong> button: share with select groups of people (public or private); no +1 option available directly in popup window; no +1 option available for the actual article <em>anywhere</em>, but you can +1 your share post (as seen in your Google+ account).</li>
<li><strong>+1</strong> button: share with select groups of people (public or private); clicking the button &#8220;plus-one&#8217;s&#8221; it and your +1 vote is counted publicly; you also have option to share right there in the popup window; you can also +1 your share post (as seen in Google+ account).</li>
</ul>
<p>Based on this, it looks like Share is for sharing only, but +1 is for both sharing and adding +1 for the article. So now I&#8217;m checking out both: Share button <em>before</em> the article, and <em>+1</em> after.. will report in a month or so as to the effectiveness or not of each one &#8212; stay tuned.</p>
<p>Related posts:</p><ol>
<li><a href='http://perishablepress.com/google-analytics-plugin/' rel='bookmark' title='Google Analytics Plugin'>Google Analytics Plugin</a></li>
<li><a href='http://perishablepress.com/google-analytics-invitation/' rel='bookmark' title='Google Analytics Invitation'>Google Analytics Invitation</a></li>
<li><a href='http://perishablepress.com/tell-google-to-not-index-certain-parts-of-your-page/' rel='bookmark' title='Tell Google to Not Index Certain Parts of Your Page'>Tell Google to Not Index Certain Parts of Your Page</a></li>
</ol><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=8fXP1aBHc-g:8r_YpOdjiuU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=8fXP1aBHc-g:8r_YpOdjiuU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=8fXP1aBHc-g:8r_YpOdjiuU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=8fXP1aBHc-g:8r_YpOdjiuU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=8fXP1aBHc-g:8r_YpOdjiuU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=8fXP1aBHc-g:8r_YpOdjiuU:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/google-share-button/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Blank Space / Whitespace Character for .htaccess</title>
		<link>http://perishablepress.com/blank-space-whitespace-character-htaccess/</link>
		<comments>http://perishablepress.com/blank-space-whitespace-character-htaccess/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 18:26:20 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14841</guid>
		<description><![CDATA[Working on the next version of the G-Series Blacklist, I needed a way to match a wide variety of UTF-8-encoded (hex) character strings. Those familiar with their site&#8217;s traffic will recognize this particular type of URI request string, which is typically associated with malicious server scanning, exploits, and other malicious behavior. As I explain in this post, pattern-matching and blocking the blank-space, or whitespace character in URL-requests is an effective way to improve the security of your [...]]]></description>
			<content:encoded><![CDATA[<p>Working on the next version of the <a href="http://perishablepress.com/5g-blacklist-2012/#g-series-blacklist" title="5G Blacklist 2012">G-Series Blacklist</a>, I needed a way to match a wide variety of <abbr title="Universal Transformation Format-8">UTF-8</abbr>-encoded (hex) character strings. Those familiar with their site&#8217;s traffic will recognize this particular type of <abbr title="Uniform Resource Identifier">URI</abbr> request string, which is typically associated with malicious server scanning, exploits, and other malicious behavior. As I explain in this post, pattern-matching and blocking the blank-space, or whitespace character in URL-requests is an effective way to improve the security of your website.</p>
<p><span id="more-14841"></span></p>
<p><span class="download"><a href="#blank-space-character" class="anchor">Skip the explanation and grab the code</a></span></p>
<h3>Examples of blank-space characters in URL requests</h3>
<p>Here is a selection of malicious <abbr title="Uniform Resource Locator">URL</abbr> patterns that I want to match and block using <abbr title="6th Generation (Blacklist)">6G</abbr> blacklist techniques (via the <a href="http://perishablepress.com/tools/utf8-hex/">UTF-8 (hex) encoder</a>):</p>
<table class="default" cellspacing="0" cellpadding="0">
<thead>
<tr style="text-align:left;">
<th>UTF-8 encoded</th>
<th>Decoded request</th>
</tr>
</thead>
<tr>
<td><code>http://example.com/hack%20*/</code></td>
<td><code>http://example.com/hack */</code></td>
</tr>
<tr>
<td><code>http://example.com/%3Ca%20href=</code></td>
<td><code>http://example.com/&lt;a href=</code></td>
</tr>
<tr>
<td><code>http://example.com/%5bNext%20URL%20in%20series%5d</code></td>
<td><code>http://example.com/[Next URL in series]</code></td>
</tr>
<tr>
<td><code>http://example.com/XHTML%20Document%20Header%20Resource</code></td>
<td><code>http://example.com/XHTML Document Header Resource</code></td>
</tr>
<tr>
<td><code>http://example.com/%22%20title=%22%22%20rel=%22nofollow</code></td>
<td><code>http://example.com/" title="" rel="nofollow</code></td>
</tr>
<tr>
<td><code>http://example.com/Apache%20Module%20mod_authz_host</code></td>
<td><code>http://example.com/Apache Module mod_authz_host</code></td>
</tr>
<tr>
<td><code>http://example.com/%27.%20get_permalink()%20.</code></td>
<td><code>http://example.com/'. get_permalink() .</code></td>
</tr>
<tr>
<td><code>http://example.com/search/%20%20%20/page/13/</code></td>
<td><code>http://example.com/search/   /page/13/</code></td>
</tr>
<tr>
<td><code>http://example.com/%20%20%20/page/8/</code></td>
<td><code>http://example.com/   /page/8/</code></td>
</tr>
<tr>
<td><code>http://example.com/%3Ca%20href=</code></td>
<td><code>http://example.com/&lt;a href=</code></td>
</tr>
<tr>
<td><code>http://example.com/%20*/</code></td>
<td><code>http://example.com/ */</code></td>
</tr>
</table>
<p>This gives you an idea of what these encoded requests are targeting using the UTF-8 (hex)-encoded characters. According to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2" title="Hypertext Transfer Protocol - HTTP/1.1 (2.2 Basic Rules)">HTTP Specification</a>, any character that is not one of the following must be encoded in order to appear legitimately within URLs:</p>
<pre><code>Regular-use characters - allowed unencoded within URLs

$ - _ . + ! * ' ( ) ,

0 1 2 3 4 5 6 7 8 9

a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</code></pre>
<p>Not included in this &#8220;safe-character&#8221; list, the humble white space (or blank space) must be encoded when included in the URL. As explained by the <a href="http://www.ietf.org/rfc/rfc1738.txt" title="Network Working Group Memo: Uniform Resource Locators (URL)">Network Working Group</a>:</p>
<blockquote><p>Characters can be unsafe for a number of reasons. The space character is unsafe because significant spaces may disappear and insignificant spaces may be introduced when URLs are transcribed or typeset or subjected to the treatment of word-processing programs.</p></blockquote>
<p>Looking back at our target URLs, we find that the least common denominator is the encoded whitespace character, <code>%20</code>. Oh sure, there are plenty of other encoded characters that could be targeted, but zeroing in on blank spaces in the URL is an effective way to catch and block <em>many</em> of these types of malicious requests.</p>
<h3 id="blank-space-character">How to match the blank-space/whitespace character with .htaccess</h3>
<p>Now that we have a reason to do so, let&#8217;s use <a href="http://perishablepress.com/category/web-design/htaccess/" title="Explore the 'htaccess' archive">.htaccess</a> to match and block all URL requests that include one or more whitespace characters. It&#8217;s as simple as adding this line to your root .htaccess file</p>
<pre><code>&lt;IfModule mod_alias.c&gt;
 RedirectMatch 403 \s
&lt;/IfModule&gt;</code></pre>
<p>So the punchline to this diatribe is that an escaped &#8220;s&#8221; character (<code>\s</code>) is the regex to match blank spaces when using .htaccess directives via <code>mod_alias</code> (<code>RedirectMatch</code>) and <code>mod_rewrite</code> (<code>RewriteRule</code>). Here is an example using Apache&#8217;s <code>mod_rewrite</code>:</p>
<pre><code>&lt;IfModule mod_rewrite.c&gt;
 RewriteCond %{REQUEST_URI} !^/$
 RewriteCond %{REQUEST_URI} \s
 RewriteRule .* http://perishablepress.com/ [R=301,L]
&lt;/IfModule&gt;</code></pre>
<p>This example will redirect any requests that include whitespace to the home page (edit to match your own URL). To block them instead, replace the <code>RewriteRule</code> with this:</p>
<p><code>RewriteRule .* - [F,L]</code></p>
<p>Note that it doesn&#8217;t matter if the initial requests are encoded or not &mdash; the end result of any encoded request is the un-encoded, canonical URL (<strong>not</strong> including the query string), so targeting literal whitespace in the request URI is effective. In fact, you should only use this method if you know what you are doing and are certain that none of your URLs contain whitespace or blank spaces.</p>
<h3>Matching whitespace in query strings</h3>
<p>Wrapping up, here is how to block blank spaces in the query-string portion of the URL, which is impossible using either of the previous two examples. Using <code>mod_rewrite</code>, we can target the <code>%{QUERY_STRING}</code> variable to catch any whitespace:</p>
<pre><code>&lt;IfModule mod_rewrite.c&gt;
 RewriteCond %{REQUEST_URI} !^/$
 RewriteCond %{QUERY_STRING} \s
 RewriteRule .* - [F,L]
&lt;/IfModule&gt;</code></pre>
<p>No editing required &mdash; just drop into your .htaccess file and good to go. As always, comments and questions welcome, and thanks for reading! :)</p>
<p>Related posts:</p><ol>
<li><a href='http://perishablepress.com/unicode-character-reference-for-bloggers/' rel='bookmark' title='Unicode Character Reference for Bloggers'>Unicode Character Reference for Bloggers</a></li>
<li><a href='http://perishablepress.com/url-character-codes/' rel='bookmark' title='URL Character Codes'>URL Character Codes</a></li>
<li><a href='http://perishablepress.com/open-external-links-as-blank-targets-via-unobtrusive-javascript/' rel='bookmark' title='Open External Links as Blank Targets via Unobtrusive JavaScript'>Open External Links as Blank Targets via Unobtrusive JavaScript</a></li>
</ol><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=mTHVM6qRdcc:J-fXtWlgGBc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=mTHVM6qRdcc:J-fXtWlgGBc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=mTHVM6qRdcc:J-fXtWlgGBc:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=mTHVM6qRdcc:J-fXtWlgGBc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=mTHVM6qRdcc:J-fXtWlgGBc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=mTHVM6qRdcc:J-fXtWlgGBc:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/blank-space-whitespace-character-htaccess/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Case-Insensitive RedirectMatch</title>
		<link>http://perishablepress.com/case-insensitive-redirectmatch/</link>
		<comments>http://perishablepress.com/case-insensitive-redirectmatch/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 17:42:51 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14821</guid>
		<description><![CDATA[Cool trick that you may not have known about.. it&#8217;s possible to get case-insensitive matching with the powerful RedirectMatch directive. Normally, you would just write your redirect as something like this: RedirectMatch 301 /phpMyAdmin http://example.com/somewhere-else/ This works great, but it&#8217;s case-sensitive. You could just match the all-lowercase version, but there are some phrases &#8212; such as &#8220;phpMyAdmin&#8221; &#8212; that really benefit from going the case-insensitive route. Those familiar with Apache might be screaming, &#8220;just use a rewrite [...]]]></description>
			<content:encoded><![CDATA[<p>Cool trick that you may not have known about.. it&#8217;s possible to get <a href="#i" title="Skip ahead and grab the code" class="anchor">case-insensitive matching</a> with the powerful <code>RedirectMatch</code> directive. Normally, you would just write your redirect as something like this:</p>
<p><span id="more-14821"></span></p>
<p><code>RedirectMatch 301 /phpMyAdmin http://example.com/somewhere-else/</code></p>
<p>This works great, but it&#8217;s case-<em>sensitive</em>. You <em>could</em> just match the all-lowercase version, but there are some phrases &mdash; such as &#8220;phpMyAdmin&#8221; &mdash; that really benefit from going the case-insensitive route. Those familiar with Apache might be screaming, &#8220;just use a rewrite rule!&#8221; Something like this will certainly get you there:</p>
<pre><code>&lt;IfModule mod_rewrite.c&gt;
 RewriteCond %{REQUEST_URI} /phpMyAdmin [NC]
 RewriteRule .* http://example.com/somewhere-else/ [R=301,L] 
&lt;/IfModule&gt;</code></pre>
<p>Notice the <code>[NC]</code> flag? That tells Apache to ignore casing for the pattern match. This works great, but there are situations where you would rather just keep it simple with good &lsquo;ol <code>RedirectMatch</code>. When? Let me give you an example with the recent <a href="http://perishablepress.com/wordpress-5g-blacklist/" title="WordPress Add-on for 5G Blacklist">WordPress add-on</a> for the <a href="http://perishablepress.com/5g-blacklist-2012/" title="5G Blacklist 2012">5G Blacklist</a>, which originally looked like this:</p>
<pre><code># 5G WP
RedirectMatch 403 /\$\&amp;
RedirectMatch 403 /\.(bash|git|hg|log|svn|swp|tar)
RedirectMatch 403 /(1|contact|i|index1|iprober|phpinfo|phpspy|product|signup|t|test|timthumb|tz|visit|webshell|wp-signup).php
RedirectMatch 403 /(author-panel|class|database|manage|phpMyAdmin|register|submit-articles|system|usage|webmaster)/?$
RedirectMatch 403 /(=|_mm|cgi|cvs|dbscripts|jsp|rnd|userfiles)</code></pre>
<p>Simple and effective, made super lightweight and awesome mainly because of the flexible <code>RedirectMatch</code> directive. But notice the &ldquo;<code>phpMyAdmin</code>&rdquo; in the penultimate directive &mdash; as <a href="http://wptest.means.us.com/">Andy W</a> reminds us:</p>
<blockquote><p>Your WP blacklist checks for “phpMyAdmin”. As I understand it RedirectMatch is case sensitive so it wouldn’t block “phpmyadmin” (all lowercase) which I recollect seeing on old logs for my site.</p></blockquote>
<p>Pattern-matching with case-insensitivity increases the scope of your .htaccess redirect rules. For the <code>RedirectMatch</code> directive, here&#8217;s how to do it..</p>
<h3 id="i">Case-Insensitive RedirectMatch</h3>
<p>Fortunately, Apache makes it easy to declare case-insensitivity with <code>RedirectMatch</code>. Simply precede the pattern with &ldquo;<code>(?i)</code>&rdquo; (without the quotes). Returning to our initial example, we can get case-insensitivity like so:</p>
<p><code>RedirectMatch 301 (?i)/phpMyAdmin http://example.com/somewhere-else/</code></p>
<p>That&#8217;s all you need to match all the crazy variations for requests such as <a href="http://www.phpmyadmin.net/">phpMyAdmin</a>:</p>
<ul>
<li>phpMYadmin</li>
<li>PHPmyAdmin</li>
<li>phpmyadmin</li>
<li>PHPMYADMIN</li>
<li>PHPMyAdmin</li>
<li>phpMyAdmin</li>
</ul>
<p>And here is the 5G WP add-on, now with case-insensitivity:</p>
<pre><code>RedirectMatch 403 /\$\&amp;
RedirectMatch 403 (?i)/\.(bash|git|hg|log|svn|swp|tar)
RedirectMatch 403 (?i)/(1|contact|i|index1|iprober|phpinfo|phpspy|product|signup|t|test|timthumb|tz|visit|webshell|wp-signup).php
RedirectMatch 403 (?i)/(author-panel|class|database|manage|phpMyAdmin|register|submit-articles|system|usage|webmaster)/?$
RedirectMatch 403 (?i)/(=|_mm|cgi|cvs|dbscripts|jsp|rnd|userfiles)</code></pre>
<p>When it comes to redirecting most requests, its all lowercase anyway. Or you can use <code>RewriteRule</code> to establish case-insensitivity. But for some situations, it&#8217;s good to know that you can also roll with <code>RedirectMatch</code> by simply adding the <code>(?i)</code> to the rule.</p>
<p>Related posts:</p><ol>
<li><a href='http://perishablepress.com/building-the-3g-blacklist-part-4/' rel='bookmark' title='Building the 3G Blacklist, Part 4: Improving the RedirectMatch Directives of the Original 2G Blacklist'>Building the 3G Blacklist, Part 4: Improving the RedirectMatch Directives of the Original 2G Blacklist</a></li>
<li><a href='http://perishablepress.com/php-redirect-subdirectory-url-to-parent-directory/' rel='bookmark' title='Redirect any Subordinate URL to its Parent Directory via PHP'>Redirect any Subordinate URL to its Parent Directory via PHP</a></li>
<li><a href='http://perishablepress.com/redirect-subdirectory-to-root-via-htaccess/' rel='bookmark' title='Redirecting Subdirectories to the Root Directory via HTAccess'>Redirecting Subdirectories to the Root Directory via HTAccess</a></li>
</ol><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=dDiY3xfxP0E:ZTsEkzPqMEw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=dDiY3xfxP0E:ZTsEkzPqMEw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=dDiY3xfxP0E:ZTsEkzPqMEw:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=dDiY3xfxP0E:ZTsEkzPqMEw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=dDiY3xfxP0E:ZTsEkzPqMEw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=dDiY3xfxP0E:ZTsEkzPqMEw:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/case-insensitive-redirectmatch/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress Add-on for 5G Blacklist</title>
		<link>http://perishablepress.com/wordpress-5g-blacklist/</link>
		<comments>http://perishablepress.com/wordpress-5g-blacklist/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 16:50:39 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[firewall]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14820</guid>
		<description><![CDATA[Ill requests and malicious scans have been spiking recently, to the point where server performance was really taking a hit. One scan in particular hammered the server with thousands of bad requests in just a few minutes. There are people out there with strong scripts and small minds that are constantly scanning sites for vulnerabilities, and much of what I&#8217;ve seen is aimed primarily at WordPress. That sort of mindless phishing and scanning for crumbs and holes [...]]]></description>
			<content:encoded><![CDATA[<p>Ill requests and malicious scans have been spiking recently, to the point where server performance was really taking a hit. One scan in particular hammered the server with thousands of bad requests in just a few minutes. There are people out there with strong scripts and small minds that are constantly scanning sites for vulnerabilities, and much of what I&#8217;ve seen is aimed primarily at WordPress.</p>
<p><span id="more-14820"></span></p>
<p>That sort of mindless phishing and scanning for crumbs and holes is just silly. So I whipped up this <strong>WordPress add-on</strong> for the <a href="http://perishablepress.com/5g-blacklist-2012/">5G Blacklist</a>, for those who are using it. For those who aren&#8217;t but <em>are</em> using WordPress, this add-on works perfectly well on its own &mdash; i.e., you don&#8217;t need the <abbr title="5th Generation">5G</abbr> to use it.</p>
<h3>5G WordPress Add-on</h3>
<p><abbr title="5th Generation">5G</abbr> <abbr title="WordPress">WP</abbr> add-on is designed to help protect your site against a broad spectrum of bad <abbr title="Uniform Resource Locator">URL</abbr> requests, focusing on the latest wave of malicious server scans. Simply copy/paste the following code into your site&#8217;s root <a href="http://perishablepress.com/category/web-design/htaccess/">.htaccess</a> file (beneath the 5G, if present):</p>
<pre><code># 5G:[WordPress]
&lt;ifModule mod_rewrite.c&gt;
 RedirectMatch 403 /\$\&amp;
 RedirectMatch 403 (?i)/\&amp;(t|title)=
 RedirectMatch 403 (?i)/\.(bash|git|hg|log|svn|swp|tar)
 RedirectMatch 403 (?i)/(1|contact|i|index1|iprober|phpinfo|phpspy|product|signup|t|test|timthumb|tz|visit|webshell|wp-signup).php
 RedirectMatch 403 (?i)/(author-panel|class|database|manage|phpMyAdmin|register|submit-articles|system|usage|webmaster)/?$
 RedirectMatch 403 (?i)/(=|_mm|cgi|cvs|dbscripts|jsp|rnd|shadow|userfiles)
&lt;/ifModule&gt;</code></pre>
<p>No editing is required up front, but you may need to fine-tune depending on which plugins, themes you may be using. For example, if the XYZ widget suddenly stops working, remove the 5G add-on from your .htaccess file and either 1) walk away, 2) test further and remove the offending character string. If all else fails, leave a comment and someone will try to help.</p>
<p>I can only do so much testing, so if you notice anything weird or if something breaks, leave a comment or <a href="http://perishablepress.com/contact/">send an email</a> &mdash; your feedback will help make the 5G add-on even better.</p>
<h3>How it works, what it does</h3>
<p>Once the code is in place, all <abbr title="Uniform Resource Locator">URL</abbr> requests are checked against each of the character strings. For example, let&#8217;s say some scumbag attacks your site (as they did with mine recently) with a barrage of random strings:</p>
<pre><code>http://example.com/tag/icons/rndWRr8VfM0B
http://example.com/tag/icons/rndqyG87KROd
http://example.com/tag/icons/rnd2JSAL4n8a
http://example.com/tag/icons/rndA52wTv0ma
http://example.com/tag/icons/rndUDESMbgRC
http://example.com/tag/icons/rndy24JOTQrN
http://example.com/tag/icons/rndCHSkcgPNP
http://example.com/tag/icons/rndXd9XF8il5
http://example.com/tag/icons/rndUFvb60VNk
http://example.com/tag/icons/rndBCvCRsKnB
.
.
.</code></pre>
<p>The 5G directives check the URLs and match them against the &ldquo;<code>/rnd</code>&rdquo; character string, and then silently blocks the entire swarm from accessing your site. And that&#8217;s just <em>one</em> of many bad requests that are blocked, here&#8217;s a list showing some of the <a href="http://perishablepress.com/wp/wp-content/online/code/5G-WP-blocked-strings.txt" title="Examples of blocked requests">other requests blocked by the 5G add-on</a>.</p>
<p>For whatever reason, those phrases, files, and directories are among the most heavily scanned-for resources in recent months. The <a href="http://perishablepress.com/wordpress-5g-blacklist/">5G WP add-on</a> aims to neutralize this new wave of attacks by working <em>with</em> the <a href="http://perishablepress.com/5g-blacklist-2012/">5G Blacklist</a>, but is also effective as stand-alone protection for your WordPress-powered site.</p>
<p>Related posts:</p><ol>
<li><a href='http://perishablepress.com/building-the-3g-blacklist-part-4/' rel='bookmark' title='Building the 3G Blacklist, Part 4: Improving the RedirectMatch Directives of the Original 2G Blacklist'>Building the 3G Blacklist, Part 4: Improving the RedirectMatch Directives of the Original 2G Blacklist</a></li>
<li><a href='http://perishablepress.com/5g-blacklist-2012/' rel='bookmark' title='5G Blacklist 2012'>5G Blacklist 2012</a></li>
<li><a href='http://perishablepress.com/latest-blacklist-entries/' rel='bookmark' title='Latest Blacklist Entries'>Latest Blacklist Entries</a></li>
</ol><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=sTrjZM1qlNQ:HOdedkA1jGI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=sTrjZM1qlNQ:HOdedkA1jGI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=sTrjZM1qlNQ:HOdedkA1jGI:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=sTrjZM1qlNQ:HOdedkA1jGI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=sTrjZM1qlNQ:HOdedkA1jGI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=sTrjZM1qlNQ:HOdedkA1jGI:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/wordpress-5g-blacklist/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Redirect WordPress Date Archives with .htaccess</title>
		<link>http://perishablepress.com/redirect-wordpress-date-archives-htaccess/</link>
		<comments>http://perishablepress.com/redirect-wordpress-date-archives-htaccess/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 22:25:18 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[permalinks]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://perishablepress.com/?p=14816</guid>
		<description><![CDATA[Restructuring a WordPress website may involve removing the subdomain from URLs/permalinks. For example, I recently removed the original WP-install subdirectory from Perishable Press to simplify site structure and optimize WordPress permalinks. There are PHP scripts and WP plugins that might work for this, but in most cases .htaccess is optimal when changing URL structure and redirecting traffic. Here&#8217;s a quick example to help visualize the concept: Old structure (w/ subdomain) http://perishablepress.com/press/2011/ http://perishablepress.com/press/2011/02/ http://perishablepress.com/press/2011/02/15/ New structure (w/out subdomain) [...]]]></description>
			<content:encoded><![CDATA[<p>Restructuring a WordPress website may involve <em>removing the subdomain</em> from <abbr title="Uniform Resource Locator">URL</abbr>s/permalinks. For example, I recently removed the original <abbr title="WordPress">WP</abbr>-install subdirectory from <a href="http://perishablepress.com/">Perishable Press</a> to simplify site structure and <a href="http://perishablepress.com/wordpress-permalinks-htaccess/">optimize WordPress permalinks</a>. There are <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> scripts and <abbr title="WordPress">WP</abbr> plugins that might work for this, but in most cases <a href="http://perishablepress.com/category/htaccess/" title="Archive for .htaccess">.htaccess</a> is <em>optimal</em> when changing <abbr title="Uniform Resource Locator">URL</abbr> structure and redirecting traffic. Here&#8217;s a quick example to help visualize the concept:</p>
<p><span id="more-14816"></span></p>
<p><strong>Old structure (w/ subdomain)</strong><br />
<code>http://perishablepress.com/press/2011/</code><br />
<code>http://perishablepress.com/press/2011/02/</code><br />
<code>http://perishablepress.com/press/2011/02/15/</code></p>
<p><strong>New structure (w/out subdomain)</strong><br />
<code>http://perishablepress.com/2011/</code><br />
<code>http://perishablepress.com/2011/02/</code><br />
<code>http://perishablepress.com/2011/02/15/</code></p>
<p>We also want to redirect date-archive permalinks when they&#8217;re <strong>paged</strong> or missing the trailing slash. Note that here we&#8217;re dealing with WordPress <strong>date archives</strong>, which is different than simply removing the &#8220;year/month/day&#8221; from your single-post permalinks. We&#8217;ll get to doing that a bit later, for now let&#8217;s remove the subdirectory from the date-based archives.</p>
<h3>Redirecting date archives</h3>
<p>First, if you&#8217;re familiar with using .htaccess, you may be asking, &#8220;why is this even necessary? Why not just redirect *everything* from the subdirectory?&#8221; Good question. If you have WP installed in a subdirectory structure like this:</p>
<p><code>example.com/wordpress/</code><br />
<code>example.com/wordpress/wp-admin/</code><br />
<code>example.com/wordpress/wp-content/</code><br />
<code>example.com/wordpress/wp-includes/</code><br />
<code>...</code></p>
<p>..and want to redirect to basically the same thing, only <em>without</em> the <code>wordpress</code> subdirectory:</p>
<p><code>example.com/</code><br />
<code>example.com/wp-admin/</code><br />
<code>example.com/wp-content/</code><br />
<code>example.com/wp-includes/</code><br />
<code>...</code></p>
<p>such that there is basically a one-to-one correspondence between old and new files, then YES you can just redirect everything wholesale with a simple line of .htaccess:</p>
<p><code>RedirectMatch 301 ^/wordpress/(.*) http://example.com/$1</code></p>
<p>and be done with it &mdash; no need to bother with the other redirect methods in this tutorial. If, however, your site restructuring is more complicated, perhaps involving stuff like:</p>
<ul>
<li>you also want to remove the year/month/day from your single-post permalinks</li>
<li>you are removing/renaming/consolidating directories, so not 1-to-1</li>
<li>you are changing tag/category/taxonomy names, so not 1-to-1</li>
<li>other subdirectory installations of WordPress are involved</li>
<li>you&#8217;re just nuts for even thinking about this crazy stuff</li>
</ul>
<p>If any of these apply, then the <em>easy way</em> is out and you&#8217;ve got some thinking to do. I&#8217;m here to help with that, starting with redirecting your date-based archives. Here is the magic code to add to your site&#8217;s root .htaccess file (after making a backup copy of the original):</p>
<pre><code># REDIRECT WP DATE ARCHIVES
RedirectMatch 301 ^/wordpress/([0-9]+)/?$         http://example.com/$1/
RedirectMatch 301 ^/wordpress/([0-9]+)/page/(.*)$ http://example.com/$1/page/$2

RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)/?$         http://example.com/$1/$2/
RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)/page/(.*)$ http://example.com/$1/$2/page/$3

RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)/([0-9]+)/?$         http://example.com/$1/$2/$3/
RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)/([0-9]+)/page/(.*)$ http://example.com/$1/$2/$3/page/$4</code></pre>
<p>There are three sections to this code: yearly archives, monthly archives, and daily archives. The only editing that you need to do is change the &ldquo;<code>wordpress</code>&rdquo; in each line to match your subdirectory&#8217;s name, and then also replace all instances of <code>example.com</code> with your domain name.</p>
<h3>Eliminate all date-based archives</h3>
<p>You may have asked at some point, &#8220;why bother at all with date-based archives?&#8221; After all, it&#8217;s redundant info that may contribute to &#8220;duplicate-content&#8221; penalties in search-engine results. I think most blogs these days emphasize categories and tags over the myriad other archive types. Many themes tend to ignore the date-based archives and popular <abbr title="Search Engines Optimization">SEO</abbr> plugins provide easy ways of no-indexing/removing them from search engines. So let&#8217;s just eliminate date archives entirely, say by redirecting all of it to your home page, where the additional link equity may provide some SEO benefits to your site. So that&#8217;s the <em>spiel</em> &mdash; here&#8217;s how to do it..</p>
<h4>Step 1</h4>
<p>Add the following code to your site&#8217;s root .htaccess file:</p>
<pre><code># REDIRECT DATE ARCHIVES TO HOME PAGE
RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)?/?([0-9]+)?/?$    http://example.com/
RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)?/?([0-9]+)?/?page http://example.com/</code></pre>
<p>As discussed in the previous section, edit or remove the subdomain to match your own, and then change the <code>example.com</code> to whatever makes sense (e.g., your home page). Test thoroughly using as many different archive/permalink formats as possible.</p>
<h4>Step 2</h4>
<p>Once the date archives have been redirected via .htaccess, you should go through your theme and remove/edit any date-based archive links and/or code. A typical location for such would be <code>archive.php</code>, <code>archives.php</code>, <code>index.php</code>, and of course <code>date.php</code> if it actually exists. Once your theme is cleaned up, you&#8217;re all set, but should keep an eye on any weird activity in your traffic logs. As straightforward as it seems, it&#8217;s a big move, and you want to be careful.</p>
<h3>Removing year/month/day from single-post permalinks</h3>
<p>Removing the year/month/day from your single-post permalinks is another way to improve the <abbr title="Search Engine Optimization">SEO</abbr> integrity of your WordPress-powered site. Here&#8217;s the code to do it via .htaccess:</p>
<pre><code># REMOVE DATE FROM WP POST PERMALINKS
RedirectMatch 301 ^/wordpress/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://example.com/$4</code></pre>
<p>As-is, this technique also removes the subdirectory (<code>/wordpress/</code>), so edit accordingly or remove if not needed. Once in place, this code will change your single-view permalinks from overkill:</p>
<p><code>http://example.com/wordpress/2012/04/12/post-name/</code></p>
<p>..to elegance:</p>
<p><code>http://example.com/post-name/</code></p>
<p>Remember to test thoroughly after making any changes! As always, questions &amp; comments welcome. Thanks for reading :)</p>
<p><em>No related articles for this post. <a href="http://perishablepress.com/archives/">Visit the archives</a></em></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vJYqF0UzbkY:fmnBaGh4_lM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vJYqF0UzbkY:fmnBaGh4_lM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vJYqF0UzbkY:fmnBaGh4_lM:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vJYqF0UzbkY:fmnBaGh4_lM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vJYqF0UzbkY:fmnBaGh4_lM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vJYqF0UzbkY:fmnBaGh4_lM:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/redirect-wordpress-date-archives-htaccess/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

