<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Parmendra&#039;s PHP Blog</title>
	<atom:link href="http://parmendra.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://parmendra.wordpress.com</link>
	<description>Feel the power of web</description>
	<lastBuildDate>Tue, 10 Jan 2012 05:26:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='parmendra.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Parmendra&#039;s PHP Blog</title>
		<link>http://parmendra.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://parmendra.wordpress.com/osd.xml" title="Parmendra&#039;s PHP Blog" />
	<atom:link rel='hub' href='http://parmendra.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to copy file from one folder to other using PHP</title>
		<link>http://parmendra.wordpress.com/2012/01/10/how-to-copy-file-from-one-folder-to-other-using-php/</link>
		<comments>http://parmendra.wordpress.com/2012/01/10/how-to-copy-file-from-one-folder-to-other-using-php/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 05:26:54 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[copy file from one folder to other]]></category>
		<category><![CDATA[Copy]]></category>
		<category><![CDATA[File]]></category>
		<category><![CDATA[other folder]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=141</guid>
		<description><![CDATA[Hi Guys! There are very few steps to achieve that target You should know the folder name and file name from where you want to copy your file Lets take a example i want to copy my file test.docx from test folder to upload folder &#60;?php $source = &#8216;test/test.docx&#8217;; $destination = &#8216;upload/test.docx&#8217; ; // copy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=141&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi Guys!</p>
<p>There are very few steps to achieve that target</p>
<p>You should know the folder name and file name from where you want to copy your file</p>
<p>Lets take a example i want to copy my file test.docx from test folder to upload folder</p>
<p>&lt;?php</p>
<p>$source = &#8216;test/test.docx&#8217;;</p>
<p>$destination = &#8216;upload/test.docx&#8217; ;</p>
<p>// copy start here</p>
<p>if(@copy($source, $destination)){</p>
<p>echo &#8220;File copied successfully&#8221;;</p>
<p>}</p>
<p>Thats it.</p>
<p>Have fun</p>
<br />Filed under: <a href='http://parmendra.wordpress.com/category/copy-file-from-one-folder-to-other/'>copy file from one folder to other</a> Tagged: <a href='http://parmendra.wordpress.com/tag/copy/'>Copy</a>, <a href='http://parmendra.wordpress.com/tag/file/'>File</a>, <a href='http://parmendra.wordpress.com/tag/other-folder/'>other folder</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=141&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2012/01/10/how-to-copy-file-from-one-folder-to-other-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>No input file specified error</title>
		<link>http://parmendra.wordpress.com/2011/02/04/no-input-file-specified-error/</link>
		<comments>http://parmendra.wordpress.com/2011/02/04/no-input-file-specified-error/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 07:50:17 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[No input file specified]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=136</guid>
		<description><![CDATA[I have found today very interesting problem while working on mod_rewrite. The whole thing is working fine on my local system, but once i have uploaded my website to Godaddy server, Suddenly all went wrong i found &#8220;No input file specified&#8221;. I googling to find solution, but not fruit full for me. then i contact [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=136&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have found today very interesting problem while working on mod_rewrite.</p>
<p>The whole thing is working fine on my local system, but once i have uploaded my website to Godaddy server, Suddenly all went wrong</p>
<p>i found <strong>&#8220;No input file specified&#8221;</strong>.</p>
<p>I googling to find solution, but not fruit full for me.</p>
<p>then i contact to my server guy.</p>
<p>a very little thing but very precious .</p>
<div>
<div>
<pre>RewriteEngine On

Options +FollowSymLinks
Options -MultiViews
</pre>
</div>
</div>
<p>and every thing working fine for Go Daddy Server.</p>
<br />Filed under: <a href='http://parmendra.wordpress.com/category/uncategorized/'>Uncategorized</a> Tagged: <a href='http://parmendra.wordpress.com/tag/no-input-file-specified/'>No input file specified</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=136&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2011/02/04/no-input-file-specified-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Fix ereg is deprecated errors in PHP 5.3</title>
		<link>http://parmendra.wordpress.com/2010/07/17/fix-ereg-is-deprecated-errors-in-php-5-3/</link>
		<comments>http://parmendra.wordpress.com/2010/07/17/fix-ereg-is-deprecated-errors-in-php-5-3/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 09:45:02 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[ereg is deprecated errors]]></category>
		<category><![CDATA[ereg]]></category>
		<category><![CDATA[ereg deprecated]]></category>
		<category><![CDATA[eregi]]></category>
		<category><![CDATA[ereg_replace]]></category>
		<category><![CDATA[preg_match]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=131</guid>
		<description><![CDATA[Hi Guys, Some time back i have faced a very interesting Problem, I have installed PHP 5.3 version, This cause problem in my Oscommerce website, I found &#8220;ereg is deprecated&#8221; solution : Here How you can fix it, To migrate ereg(): ereg('\.([^\.]*$)', $this-&#62;file_src_name, $extension); becomes preg_match('/\.([^\.]*$)/', $this-&#62;file_src_name, $extension); Notice that I wrapped the pattern (\.([^\.]*$)) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=131&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi Guys,</p>
<p>Some time back i have faced a very interesting Problem,<br />
I have installed PHP 5.3 version, This cause problem in my Oscommerce website,</p>
<p>I found &#8220;ereg is deprecated&#8221; solution :</p>
<p>Here How you can fix it,</p>
<p>To migrate ereg():</p>
<div>
<div>
<pre><strong>ereg('\.([^\.]*$)', $this-&gt;file_src_name, $extension);</strong></pre>
</div>
</div>
<p>becomes</p>
<div>
<div>
<pre><strong>preg_match('/\.([^\.]*$)/', $this-&gt;file_src_name, $extension);</strong></pre>
</div>
</div>
<p>Notice that I wrapped the pattern (\.([^\.]*$))   around / /, which are RegExp delimiters. If   you find yourself escaping / too much (for   an URL for example), you might want to use the #   delimiter instead.</p>
<p>To migrate ereg_replace():</p>
<div>
<div>
<pre><strong>$this-&gt;file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '',
 $this-&gt;file_dst_name_body);</strong></pre>
</div>
</div>
<p>becomes</p>
<div>
<div>
<pre><strong>$this-&gt;file_dst_name_body = preg_replace('/[^A-Za-z0-9_]/', '',
 $this-&gt;file_dst_name_body);</strong></pre>
</div>
</div>
<p>Again, I just added delimiters to the pattern.</p>
<p>If you are using eregi functions (which are   the case-insensitive version of ereg), you’ll notice there’re no   equivalent pregi functions. This is because this functionality is   handled by <em>RegExp modifiers</em>.</p>
<p>Basically, to make the pattern match characters in a case-insensitive   way, append i after the delimiter:</p>
<div>
<div>
<pre><strong>eregi('\.([^\.]*$)', $this-&gt;file_src_name, $extension);</strong></pre>
</div>
</div>
<p>becomes</p>
<div>
<div>
<pre><strong>preg_match('/\.([^\.]*$)/i', $this-&gt;file_src_name, $extension);

</strong>

Hope this will help you.

Enjoy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </pre>
</div>
</div>
<br />Filed under: <a href='http://parmendra.wordpress.com/category/ereg-is-deprecated-errors/'>ereg is deprecated errors</a> Tagged: <a href='http://parmendra.wordpress.com/tag/ereg/'>ereg</a>, <a href='http://parmendra.wordpress.com/tag/ereg-deprecated/'>ereg deprecated</a>, <a href='http://parmendra.wordpress.com/tag/eregi/'>eregi</a>, <a href='http://parmendra.wordpress.com/tag/ereg_replace/'>ereg_replace</a>, <a href='http://parmendra.wordpress.com/tag/preg_match/'>preg_match</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=131&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2010/07/17/fix-ereg-is-deprecated-errors-in-php-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP mail function used to send with attachment</title>
		<link>http://parmendra.wordpress.com/2009/07/14/php-mail-function-used-to-send-attachment/</link>
		<comments>http://parmendra.wordpress.com/2009/07/14/php-mail-function-used-to-send-attachment/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 06:08:25 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[php mail function with attachment]]></category>
		<category><![CDATA[chunk_split]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mail send through php]]></category>
		<category><![CDATA[php mail function]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=99</guid>
		<description><![CDATA[PHP mail function used to send attachments PHP attachement mail function, Using this function which is very usefull for sending mail with attachment. You can attached jpg, gif, png, pdf, els, doc etc. This function is used attach multiple files. The size of attchement is totaly depends on server php.ini setting $AttmFiles is an array. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=99&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>PHP mail function used to send attachments</h2>
<p>PHP attachement mail function,<br />
Using this function which is very usefull for sending mail with attachment.</p>
<p>You can attached jpg, gif, png, pdf, els, doc etc.<br />
This function is used attach multiple files.</p>
<p>The size of attchement is totaly depends on server php.ini setting<br />
$AttmFiles is an array.</p>
<p>You just pass multiple file path which you want to attach.</p>
<p>This mail function return true after succesion other wise return false.</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<h3><strong>Veriable description</strong></h3>
<div style="background-color:#f4f4f4;text-align:left;">
<p><strong>Function parameters </strong></p>
<p>$From &#8212;&gt; Sender mail address<br />
$FromName &#8212;&gt; Sender&#8217;s Name<br />
$To &#8212;&gt; Receiver&#8217;s Mail address<br />
$ToName &#8212;&gt; Receivers&#8217;s Name<br />
$Subject &#8212;&gt; Subject<br />
$Text &#8212;&gt; Plain text message<br />
$Html &#8212;&gt; Html message<br />
$AttmFiles &#8212;&gt;Array. files to send in attachment</p></div>
<div style="background-color:#f4f4f4;text-align:left;">
<blockquote><p>function SendMail($From,$FromName,$To,$ToName,$Subject,$Text,$Html,</p>
<p>$AttmFiles){</p>
<p>$OB=&#8221;&#8212;-=_OuterBoundary_000&#8243;;</p>
<p>$IB=&#8221;&#8212;-=_InnerBoundery_001&#8243;;</p>
<p>$Html=$Html?$Html:preg_replace(&#8220;/\n/&#8221;,&#8221;{br}&#8221;,$Text) or die(&#8220;neither text nor html part present.&#8221;);</p>
<p>$Text=$Text?$Text:&#8221;Sorry, but you need an html mailer to read this mail.&#8221;;</p>
<p>$From or die(&#8220;sender address missing&#8221;);</p>
<p>$To or die(&#8220;recipient address missing&#8221;);</p>
<p>$headers =&#8221;MIME-Version: 1.0\r\n&#8221;;</p>
<p>$headers.=&#8221;From: &#8220;.$FromName.&#8221; &lt;&#8221;.$From.&#8221;&gt;\n&#8221;;</p>
<p>$headers.=&#8221;To: &#8220;.$ToName.&#8221; &lt;&#8221;.$To.&#8221;&gt;\n&#8221;;</p>
<p>$headers.=&#8221;Reply-To: &#8220;.$FromName.&#8221; &lt;&#8221;.$From.&#8221;&gt;\n&#8221;;</p>
<p>$headers.=&#8221;X-Priority: 1\n&#8221;;</p>
<p>$headers.=&#8221;X-MSMail-Priority: High\n&#8221;;</p>
<p>$headers.=&#8221;X-Mailer: My PHP Mailer\n&#8221;;</p>
<p>$headers.=&#8221;Content-Type: multipart/mixed;\n\tboundary=\&#8221;".$OB.&#8221;\&#8221;\n&#8221;;</p>
<p>//Messages start with text/html alternatives in OB</p>
<p>$Msg =&#8221;This is a multi-part message in MIME format.\n&#8221;;</p>
<p>$Msg.=&#8221;\n&#8211;&#8221;.$OB.&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Type: multipart/alternative;\n\tboundary=\&#8221;".$IB.&#8221;\&#8221;\n\n&#8221;;</p>
<p>//plaintext section</p>
<p>$Msg.=&#8221;\n&#8211;&#8221;.$IB.&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Type: text/plain;\n\tcharset=\&#8221;iso-8859-1\&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Transfer-Encoding: quoted-printable\n\n&#8221;;</p>
<p>// plaintext goes here</p>
<p>$Msg.=$Text.&#8221;\n\n&#8221;;</p>
<p>// html section</p>
<p>$Msg.=&#8221;\n&#8211;&#8221;.$IB.&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Type: text/html;\n\tcharset=\&#8221;iso-8859-1\&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Transfer-Encoding: base64\n\n&#8221;;</p>
<p>// html goes here</p>
<p>$Msg.=chunk_split(base64_encode($Html)).&#8221;\n\n&#8221;;</p>
<p>// end of IB</p>
<p>$Msg.=&#8221;\n&#8211;&#8221;.$IB.&#8221;&#8211;\n&#8221;;</p>
<p>// attachments</p>
<p>if($AttmFiles){</p>
<p>foreach($AttmFiles as $AttmFile){</p>
<p>$patharray = explode (&#8220;/&#8221;, $AttmFile);</p>
<p>$FileName=$patharray[count($patharray)-1];</p>
<p>$Msg.= &#8220;\n&#8211;&#8221;.$OB.&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Type: application/octetstream;\n\tname=\&#8221;".$FileName.&#8221;\&#8221;\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Transfer-Encoding: base64\n&#8221;;</p>
<p>$Msg.=&#8221;Content-Disposition: attachment;\n\tfilename=\&#8221;".$FileName.&#8221;\&#8221;\n\n&#8221;;</p>
<p>//file goes here</p>
<p>$fd=fopen ($AttmFile, &#8220;r&#8221;);</p>
<p>$FileContent=fread($fd,filesize($AttmFile));</p>
<p>fclose ($fd);</p>
<p>$FileContent=chunk_split(base64_encode($FileContent));</p>
<p>$Msg.=$FileContent;</p>
<p>$Msg.=&#8221;\n\n&#8221;;</p>
<p>}</p>
<p>}</p>
<p>//message ends</p>
<p>$Msg.=&#8221;\n&#8211;&#8221;.$OB.&#8221;&#8211;\n&#8221;;</p>
<p>// mailing section</p>
<p>if(mail($To,$Subject,$Msg,$headers)){</p>
<p>return true;</p>
<p>}</p>
<p>else{</p>
<p>return false;</p>
<p>}</p>
<p>}</p></blockquote>
</div>
<br />Posted in php mail function with attachment Tagged: chunk_split, mail, mail send through php, php mail function, php mail function with attachment <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=99&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/14/php-mail-function-used-to-send-attachment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>how to set cookies through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/set-cookies-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/set-cookies-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:36:19 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[setting cookies through htaccess]]></category>
		<category><![CDATA[set cookies]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=86</guid>
		<description><![CDATA[cookies Lastly, a quick word about cookies. While it&#8217;s easy enough to set cookies in .htaccess without any mod_rewrite.. create a cookie called &#8220;example-cookie&#8221;, and set its value to &#8220;true&#8221;&#8230;.. Header set Set-Cookie &#8220;example-cookie=true&#8221;&#8230;. ..you will need it to read the cookie information back again, and &#8220;do stuff&#8221; with it. It&#8217;s easy. For example, to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=86&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>cookies</h3>
<div id="cookies-in-htaccess">Lastly, a quick word about cookies. While it&#8217;s easy enough to set cookies in .htaccess without any <tt>mod_rewrite</tt>..</p>
<blockquote>
<div>
<div>create a cookie called &#8220;example-cookie&#8221;, and set its value to &#8220;true&#8221;&#8230;..</div>
<div>Header set Set-Cookie &#8220;example-cookie=true&#8221;&#8230;.</div>
</div>
</blockquote>
<p>..you <em>will</em> need it to read the cookie information back again, and &#8220;do stuff&#8221; with it. It&#8217;s easy. For example, to check if the above cookie exists and has the correct value set, we could simply do..</p>
<blockquote>
<div>
<div>check for that same cookie + value..</div>
<div>Options + FollowSymlinks<br />
RewriteEngine on<br />
RewriteCond %{HTTP_COOKIE} !my-tools=true<br />
RewriteRule .* /err/401.php</div>
</div>
</blockquote>
<p>..which could easily form the basis of a simple authentication system. As with any RewriteCond, you can get pretty complex, checking multiple cookies, utilizing regexp and more, but that&#8217;s enough to get you started.</p>
<p>Hope you will enjoy this&#8230;&#8230;  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</div>
<br />Posted in setting cookies through htaccess Tagged: set cookies <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=86&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/set-cookies-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Prevent hot-linking through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/prevent-hot-linking-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/prevent-hot-linking-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:31:42 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[prevent hot-linking through htaccess]]></category>
		<category><![CDATA[hot-linking]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=84</guid>
		<description><![CDATA[Prevent hot-linking using htaccess Believe it or not, there are some webmasters who, rather than coming up with their own content will steal yours. Really! Even worse, they won&#8217;t even bother to copy to their own server to serve it up, they&#8217;ll just link to your content! no, it&#8217;s true, in fact, it used to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=84&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Prevent hot-linking using htaccess</h1>
<p>Believe it or not, there are some webmasters who, rather than coming up with their own content will <em>steal</em> yours. Really! Even worse, they won&#8217;t even bother to copy to their own server to serve it up, they&#8217;ll just <strong>link to your content!</strong> no, it&#8217;s true, in fact, it used to be incredibly common. These days most people like to prevent this sort of thing, and .htaccess is one of the best ways to do it.</p>
<p>This is one of those directives where the mileage variables are at their limits, but something like this works fine for me..</p>
<blockquote>
<div id="rewrite-rule-prevent-hot-linking">
<div>how DARE they!</div>
<div>Options +FollowSymlinks<br />
<span># no hot-linking</span><br />
RewriteEngine On<br />
RewriteCond %{HTTP_REFERER} !^$<br />
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com/ [NC]<br />
RewriteRule .*\.(gif|jpg|png)$ http://mydomain.com/img/hotlink.png  [NC]</div>
</div>
</blockquote>
<p>You may see the last line broken into two, but it&#8217;s all one line (all the directives on this page are). Let&#8217;s have a wee look at what it does..</p>
<p>We begin by enabling the rewrite engine, as always.</p>
<p>The first <a title="'conditions', things to and match against the rewrite rule with deal with whatever requests these 'conditions' match">RewriteCond</a> line allows <em>direct</em> requests (not <em>from</em> other pages &#8211; an &#8220;empty referrer&#8221;) to pass unmolested. The next line means; <em>if</em> the browser <em>did</em> send a referrer header, and the word &#8220;<strong>mydomain.com</strong>&#8221; is <em>not in the domain part of it</em>, then <em>DO</em> rewrite this request.</p>
<p>The all-important final <a title="the magic happens here. only requests that got through all the condition statements will be processed by the rule on this line.">RewriteRule</a> line instructs <tt>mod_rewrite</tt> to rewrite all matched requests (anything without &#8220;mydomain.com&#8221; in its referrer) asking for gifs, jpegs, or pngs, to an alternative image.</p>
<br />Posted in prevent hot-linking through htaccess Tagged: hot-linking <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=84&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/prevent-hot-linking-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Ban User Agents and referrers and script-kiddies through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/ban-user-agents-and-referrers-and-script-kiddies-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/ban-user-agents-and-referrers-and-script-kiddies-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:26:54 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Ban User Agents and referrers and script-kiddies through htaccess]]></category>
		<category><![CDATA[ban  script-kiddies]]></category>
		<category><![CDATA[ban referrers]]></category>
		<category><![CDATA[Ban User Agents]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=82</guid>
		<description><![CDATA[Ban User Agents, referrers, script-kiddies using htaccess There are many valid reasons to ban a particular request from sucking up your site&#8217;s resources; resources that could be better served to valid, interested users. It might be some cross-site attack script, or inward link from a place you don&#8217;t want to be associated with, or perhaps [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=82&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Ban User Agents, referrers, script-kiddies using htaccess</h1>
<p>There are many valid reasons to ban a particular request from sucking up your site&#8217;s resources; resources that could be better served to valid, interested users. It might be some cross-site attack script, or inward link from a place you don&#8217;t want to be associated with, or perhaps a web sucker or download manager, whatever; .htaccess + <tt>mod_rewrite</tt> provides ways to protect your content from unwanted &#8220;guests&#8221;.</p>
<p>The basic formula is standard if-then logic: <em>if</em> the request meets a particular CONDITION, <em>then</em> REWRITE the request. The &#8220;conditions&#8221; can be many things; perhaps the referrer header sent by their browser (the site they came <em>from</em>), or the page they asked for, or a particular query parameter, or the type of client (browser, etc.) they are using, or any other piece of information Apache has attached to the request. Here&#8217;s an example which will deny access to &#8220;Teleport Pro&#8221;, a download manager which is known to suck, hard..</p>
<blockquote>
<div id="rewrite-this-sucker-to-my-abuse-page">
<div>Who need&#8217;s a local copy, when I&#8217;m right here?..</div>
<div>RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [NC]<br />
RewriteRule . abuse.txt [L]</div>
</div>
</blockquote>
<p>It&#8217;s your site, and just like your home, you have every right to exert some control over who gets in. You may have a <em>huge</em> list of user agents you&#8217;d rather not have eating your bandwidth; so use the <tt>[OR]</tt> flag, and <em>line &#8216;em up..</em></p>
<blockquote>
<div id="rewrite-suckers-to-my-abuse-page">
<div>A little garlic for the net vampires..</div>
<div>RewriteCond %{HTTP_USER_AGENT} ^BackWeb [NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^Bandit [NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^BatchFTP [NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^BecomeBot [NC,OR]<br />
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [NC,OR]<br />
<span># etc..</span><br />
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [NC]<br />
RewriteRule . abuse.txt [L]</div>
</div>
</blockquote>
<p>This forms the basis of what often becomes a HUGE list of ban-lines. Remember, we aren&#8217;t limited to user agent strings..</p>
<blockquote>
<div id="rewrite-anyone-to-my-abuse-page">
<div>Suckers, h4x0rz, kiddies, cross-site scripters and more.. Bye now!</div>
<div><span># why not come visit me directly?</span><br />
RewriteCond %{HTTP_REFERER} \.opendirviewer\. [NC,OR]<br />
<span># this prevents stoopid cross-site discovery attacks..</span><br />
RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]<br />
<span># please stop pretending to be the Googlebot..</span><br />
RewriteCond %{HTTP_REFERER} users\.skynet\.be.* [NC,OR]<br />
<span># really, we need a special page for these twats..</span><br />
RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]<br />
RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]<br />
RewriteCond %{REQUEST_URI} owssvr\.dll [NC,OR]<br />
<span># you can probably work these out..</span><br />
RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]<br />
RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]<br />
<span># etc..</span><br />
RewriteCond %{HTTP_USER_AGENT} Sucker [NC]<br />
RewriteRule . abuse.txt [L]</div>
</div>
</blockquote>
<p>Fortunately, <tt>mod_rewite</tt> can parse enormous lists of ban-lines in milliseconds, so feel free to be as specific and comprehensive as required.</p>
<p>As ever, <strong>thorough testing is strongly recommended</strong>. Simply send requests matching your conditions and see what happens. And importantly; normal requests, too. Firefox, Opera, Konqueror, and most other decent browsers, allow you to alter the user agent string; though you would quickly find the process tedious in a testing situation. Far better to use some tool better designed to send fake HTTP requests..</p>
<p>It&#8217;s not too difficult to mock up a web request on the command-line with any-old user agent using a scripting language like php or Perl, if you have these things available (read: most Linux/UNIX/BSD/etc. as well as many other <a title="Operating Systems">OS</a>). Many examples exist online. In fact, you could quickly create a <em>suite</em> of tests, designed to interrogate all your rewrite rules, with results logging and much more, if required. <a id="link-external-cURL" title="groks those URLs, apparently." href="http://curl.haxx.se/">cURL</a> is always useful for jobs like this, so long as you don&#8217;t add a cURL ban-line!</p>
<p>On a Windows desktop, <a id="link-external-Sam_Spade_Software" title="DO NOT DISABLE THE STARTUP QUOTES! That's my advice." href="http://preview.samspade.org/ssw/">Sam Spade</a> can send a single spoofed request with a couple of clicks, along with a stack of similarly handy tricks, and regularly proves itself invaluable.</p>
<br />Posted in Ban User Agents and referrers and script-kiddies through htaccess Tagged: ban  script-kiddies, ban referrers, Ban User Agents <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=82&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/ban-user-agents-and-referrers-and-script-kiddies-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>cooler access denied through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/cooler-access-denied-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/cooler-access-denied-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:23:43 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[cooler access denied through htaccess]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=80</guid>
		<description><![CDATA[cooler access denied using htaccess The trouble with this is the way our user gets a 403 &#8220;Access Denied&#8221; error, which is a bit like having a door slammed in your face. Fortunately, mod_rewrite comes to the rescue again and enables us to do less painful things. One method I often employ is to redirect [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=80&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>cooler access denied using htaccess</h1>
<p>The trouble with this is the way our user gets a 403 &#8220;Access Denied&#8221; error, which is a bit like having a door slammed in your face. Fortunately, mod_rewrite comes to the rescue again and enables us to do less painful things. One method I often employ is to redirect the user to the parent folder..</p>
<p>they go &#8220;huh?.. ahhh!&#8221;</p>
<p># send them up!<br />
Options +FollowSymlinks<br />
RewriteEngine on<br />
RewriteRule ^(.*)$ ../ [NC]</p>
<p>It works great, though it can be a wee bit tricky with the URLs, and you may prefer to use a harder location, which avoids potential issues in indexed directories, where folks can get in a loop..</p>
<p>they go damn! Oh!</p>
<p># send them exactly there!<br />
Options +FollowSymlinks<br />
RewriteEngine on<br />
RewriteRule ^(.*)$ /comms/hardware/router/ [NC]</p>
<p>Sometimes you&#8217;ll only want to deny access to most of the files in the directory, but allow access to maybe one or two files, or file types, easy..<br />
deny with style!</p>
<p># users can load only &#8220;special.zip&#8221;, and the css and js files.<br />
Options +FollowSymlinks<br />
RewriteEngine On<br />
RewriteCond %{REQUEST_FILENAME} !^(.+)\.css$<br />
RewriteCond %{REQUEST_FILENAME} !^(.+)\.js$<br />
RewriteCond %{REQUEST_FILENAME} !special.zip$<br />
RewriteRule ^(.+)$ /chat/ [NC]</p>
<p>Here we take the whole thing a stage further. Users can access .css (stylesheet) and javascript files without problem, and also the file called &#8220;special.zip&#8221;, but requests for any other filetypes are immediately redirected back up to the main &#8220;/chat/&#8221; directory. You can add as many types as you need. You could also bundle the filetypes into one line using | (or) syntax, though individual lines are perhaps clearer.</p>
<p>Here&#8217;s what&#8217;s currently cooking inside my /inc/ directory..</p>
<p>all-in-one control..</p>
<p>RewriteEngine on<br />
Options +FollowSymlinks<br />
# allow access with no restrictions to local machine at 192.168.1.3<br />
RewriteCond %{REMOTE_ADDR} !192.168.1.3<br />
# allow access to all .css and .js in sub-directories..<br />
RewriteCond %{REQUEST_URI} !\.css$<br />
RewriteCond %{REQUEST_URI} !\.js$<br />
# allow access to the files inside img/, but not a directory listing..<br />
RewriteCond %{REQUEST_URI} !img/(.*)\.<br />
# allow access to these particular files&#8230;<br />
RewriteCond %{REQUEST_URI} !comments.php$<br />
RewriteCond %{REQUEST_URI} !parammail.php$<br />
RewriteCond %{REQUEST_URI} !digitrack.php$<br />
RewriteCond %{REQUEST_URI} !gd-verify.php$<br />
RewriteCond %{REQUEST_URI} !post-dumper.php$<br />
RewriteCond %{REQUEST_URI} !print.php$<br />
RewriteCond %{REQUEST_URI} !source-dump.php$<br />
RewriteCond %{REQUEST_URI} !textview.php$<br />
RewriteRule ^(.*)$ / [R,NC,L]</p>
<br />Posted in cooler access denied through htaccess  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=80&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/cooler-access-denied-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>capturing variables through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/capturing-variables-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/capturing-variables-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:18:03 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[capturing variables through htaccess]]></category>
		<category><![CDATA[capturing variables]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=78</guid>
		<description><![CDATA[capturing variables through htaccess Slapping (.*) onto the end of the request part of a ReWriteRule is just fine when using a simple $_GET variable, but sometimes you want to do trickier things, like capturing particular variables and converting them into other variables in the target URL. Or something else.. When capturing variables, the first [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=78&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>capturing variables through htaccess</h1>
<div id="capturing-variables">Slapping <tt>(.*)</tt> onto the end of the request part of a <tt>ReWriteRule</tt> is just fine when using a simple <tt>$_GET</tt> variable, but sometimes you want to do trickier things, like capturing <em>particular</em> variables and converting them into <em>other</em> variables in the target URL. Or something else..</p>
<p>When capturing variables, the first thing you need to know about, is the <tt>[QSA]</tt> flag, which simply tags all the original variables back onto the end of the target url. This may be all you need, and will happen automatically for simple rewites. The second thing, is <tt>%{QUERY_STRING}</tt>, an Apache server string we can capture variables from, using simple <tt>RewriteCond</tt> (aka. <em>conditional</em> ) statements.</p>
<p><tt>RewriteCond</tt> is very like doing <tt><em>if...then...do</em></tt> in many programming languages. <em>If</em> a certain condition is true, <em>then</em> do the rewrite that follows..</p>
<p>In the following example, the <tt>RewriteCond</tt> statement checks that the query string has the <tt>foo</tt> variable set, and captures its value while it&#8217;s there. In other words, only requests for <tt>/grab</tt> that have the variable <tt>foo</tt> set, will be rewritten, and while we&#8217;re at it, we&#8217;ll also switch <tt>foo</tt>, for <tt>bar</tt>, just because we can..</p>
<blockquote>
<div id="simple-capture-variables">
<div>capturing a $_GET variable:</div>
<div>Options +FollowSymlinks<br />
RewriteEngine On<br />
RewriteCond %{QUERY_STRING} foo=(.*)<br />
RewriteRule ^grab(.*) /page.php?bar=%1</div>
</div>
</blockquote>
<p>would translate a link/user&#8217;s request for..</p>
<p><tt>http://domain.com/grab?foo=bar</tt></p>
<p>server-side, into..</p>
<p><tt>http://domain.com/page.php?bar=bar</tt></p>
<p>Which is to say, the user&#8217;s browser would be fed <tt>page.php</tt> (without an <tt>[R]</tt> flag in the <tt>RewriteRule</tt>, their address bar would still read <tt>/grab?foo=bar</tt>). The variable <tt>bar</tt> would be available to your script, with its value set to <tt>bar</tt>.  	This variable has been magically created, by simply using a regular <tt><strong>?</strong></tt> in the target of the <tt>RewriteRule</tt>, and tagging on the first captured backreference, <strong>%1</strong>.. <tt>?bar=%1</tt></p>
<p><strong>Note</strong> how we use the <code><strong>%</strong></code> character, to specify variables captured in <tt>RewriteCond</tt> statements, aka &#8220;Backreferences&#8221;. This is exactly like using <strong>$1</strong> to specify numbered backreferences captured in <tt>RewriteRule</tt> patterns, except for strings captured inside a <tt>RewriteCond</tt> statement, we use <code><strong>%</strong></code> instead of <strong>$</strong>. Simple.</p>
<p>You can use the <tt>[QSA]</tt> flag in <em>addition</em> to these query string manipulations, merge them. In the next example, the value of <tt>foo</tt> becomes the <em>directory</em> in the target URL, and the variable <tt>file</tt> is magically created. The original query string is then tagged back onto the end of the whole thing..</p>
<blockquote>
<div id="more-complex-variable-capture">
<div>QSA Overkill!</div>
<div>Options +FollowSymlinks<br />
RewriteEngine On<br />
RewriteCond %{QUERY_STRING} foo=(.+)<br />
RewriteRule ^grab/(.*) /%1/index.php?file=$1 [QSA]</div>
</div>
</blockquote>
<p>So a request for..</p>
<p><tt>http://domain.com/grab/foobar.zip?level=5&amp;foo=bar</tt></p>
<p>is translated, server-side, into..</p>
<p><tt>http://domain.com/bar/index.php?file=foobar.zip&amp;level=5&amp;foo=bar</tt></p>
<p>Depending on your needs, you could even use flat links <em>and</em> dynamic variables together, something like this could be useful..</p>
<blockquote>
<div id="variable-capture-mix-flat-and-dynamic-links">
<div>mixing flat and dynamic links in a single ruleset..</div>
<div>Options +FollowSymlinks<br />
RewriteEngine On<br />
RewriteCond %{QUERY_STRING} version=(.+)<br />
RewriteRule ^grab/([^/]+)/(.*) /%1/index.php?section=$1&amp;file=$2 [QSA]</div>
</div>
</blockquote>
<p>By the way, you can easily do the <em>opposite</em>, strip a query string from a URL, by simply putting a <tt><strong>?</strong></tt> right at the end of the taget part. This example does exactly that, whilst leaving the actual URI intact..</p>
<blockquote>
<div id="strip-variables">
<div>just a demo!</div>
<div>Options +FollowSymlinks<br />
RewriteEngine On<br />
RewriteCond %{QUERY_STRING} .<br />
RewriteRule foo.php(.*) /foo.php<strong>?</strong> [L]</div>
</div>
</blockquote>
<p>The <tt>RewriteCond</tt> statement only allows requests that have <em>something</em> in their query string, to be processed by the <tt>RewriteRule</tt>, or else we&#8217;d end up in that hellish place, dread to all mod_rewriters.. the endless loop. <tt>RewriteCond</tt> is often used like this; as a safety-net.</div>
<br />Posted in capturing variables through htaccess Tagged: capturing variables <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=78&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/capturing-variables-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>shortening URLs through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/shortening-urls-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/shortening-urls-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:16:02 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[shortening URLs through htaccess]]></category>
		<category><![CDATA[shortening URL]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=76</guid>
		<description><![CDATA[shortening URLs using .htaccess One common use of mod_rewrite is to shorten URL&#8217;s. Shorter URL&#8217;s are easier to remember and, of course, easier to type. An example.. beware the regular expression: Options +FollowSymlinks RewriteEngine On RewriteRule ^grab /public/files/download/download.php this rule would transform this user&#8217;s URL.. http://mysite/grab?file=my.zip server-side, into.. http://mysite/public/files/download/download.php?file=my.zip which is a wee trick I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=76&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>shortening URLs using .htaccess</h1>
<p>One common use of <tt>mod_rewrite</tt> is to shorten URL&#8217;s. Shorter URL&#8217;s are easier to remember and, of course, easier to type. An example..</p>
<blockquote>
<div id="rewrite-rule-short-urls">
<div>beware the regular expression:</div>
<div>Options +FollowSymlinks<br />
RewriteEngine On<br />
RewriteRule ^grab /public/files/download/download.php</div>
</div>
</blockquote>
<p>this rule would transform this user&#8217;s URL..</p>
<p><span> http://mysite/grab?file=my.zip</span></p>
<p>server-side, into..</p>
<p><span> http://mysite/public/files/download/download.php?file=my.zip</span></p>
<p>which is a wee trick I use for my distro machine, among other things. everyone likes short URL&#8217;s, and so will you; using this technique, you can move <span>/public/files/download/</span> to <em>anywhere</em> else in your site, and all the old links still work fine; simply alter your .htaccess file to reflect the new location. edit one line, done &#8211; nice &#8211; means even when stuff is way deep in your site you can have cool links like this.</p>
<br />Posted in shortening URLs through htaccess Tagged: shortening URL <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=76&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/shortening-urls-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>redirecting and rewriting through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/redirecting_and_rewriting_through_htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/redirecting_and_rewriting_through_htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 05:04:13 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[redirecting and rewriting]]></category>
		<category><![CDATA[beginning rewriting]]></category>
		<category><![CDATA[complex rewriting]]></category>
		<category><![CDATA[external redirection]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[simple rewriting]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=74</guid>
		<description><![CDATA[Redirecting and rewriting using htaccess One of the more powerful tricks of the .htaccess hacker is the ability to rewrite URLs. This enables us to do some mighty manipulations on our links; useful stuff like transforming very long URL&#8217;s into short, cute URLs, transforming dynamic ?generated=page&#38;URL&#8217;s into /friendly/flat/links, redirect missing pages, preventing hot-linking, performing automatic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=74&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Redirecting and rewriting using htaccess</h1>
<p>One of the more powerful tricks of the .htaccess hacker is the ability to rewrite URLs. This enables us to do some mighty manipulations on our links; useful stuff like transforming very long URL&#8217;s into short, cute URLs, transforming dynamic ?generated=page&amp;URL&#8217;s into /friendly/flat/links, redirect missing pages, preventing hot-linking, performing automatic language translation, and much, much more.</p>
<p>Make no mistake, mod_rewrite is complex. This isn&#8217;t the subject for a quick bite-size tech-snack, probably not even a week-end crash-course, I&#8217;ve seen guys pull off some real cute stuff with mod_rewrite, but with kudos-hat tipped firmly towards that bastard operator from hell, Ralf S. Engelschall, author of the magic module itself, I have to admit that a great deal of it still seems so much voodoo to me.</p>
<p>The way that rules can work one minute and then seem not to the next, how browser and other in-between network caches interact with rules and testing rules is often baffling, maddening. When I feel the need to bend my mind completely out of shape, I mess around with mod_rewrite!</p>
<p>After all this, it does work, and while I&#8217;m not planning on taking that week-end crash-course any time soon, I have picked up a few wee tricks myself, messing around with webservers and web sites, this place..</p>
<p>The plan here is to just drop some neat stuff, examples, things that have proven useful, and work on a variety of server setups; there are apache&#8217;s all over my LAN, I keep coming across old .htaccess files stuffed with past rewriting experiments that either worked; and I add them to my list, or failed dismally; and I&#8217;m surprised that more often these days, I can see exactly why!</p>
<p>Very little here is my own invention. Even the bits I figured out myself were already well documented, I just hadn&#8217;t understood the documents, or couldn&#8217;t find them. Sometimes, just looking at the same thing from a different angle can make all the difference, so perhaps this humble stab at URL Rewriting might be of some use. I&#8217;m writing it for me, of course. but I do get some credit for this..</p>
<p># time to get dynamic, see..<br />
RewriteRule (.*)\.htm $1.php</p>
<h1>Beginning rewriting..</h1>
<p>Whenever you use mod_rewrite (the part of apache that does all this magic), you need to do..</p>
<p>you only need to do this once per .htaccess file:</p>
<p>Options +FollowSymlinks<br />
RewriteEngine on</p>
<p>..before any ReWrite rules. note: +FollowSymLinks must be enabled for any rules to work, this is a security requirement of the rewrite engine. Normally it&#8217;s enabled in the root and you shouldn&#8217;t have to add it, but it doesn&#8217;t hurt to do so, and I&#8217;ll insert it into all the examples on this page, just in case*.</p>
<p>The next line simply switches on the rewrite engine for that folder. if this directive is in you main .htaccess file, then the ReWrite engine is theoretically enabled for your entire site, but it&#8217;s wise to always add that line before you write any redirections, anywhere.</p>
<p>* Although highly unlikely, your host may have +FollowSymLinks enabled at the root level, yet disallow its addition in .htaccess; in which case, adding +FollowSymLinks will break your setup (probably a 500 error), so just remove it, and your rules should work fine.</p>
<p>Important: While some of the directives on this page may appear split onto two lines, in your .htaccess file, they must exist completely on one line. If you drag-select and copy the directives on this page, they should paste just fine into any text editor.</p>
<h1>simple rewriting</h1>
<p>Simply put, Apache scans all incoming URL requests, checks for matches in our .htaccess file and rewrites those matching URLs to whatever we specify. something like this..</p>
<p>all requests to whatever.htm will be sent to whatever.php:</p>
<p>Options +FollowSymlinks<br />
RewriteEngine on<br />
RewriteRule ^(.*)\.htm$ $1.php [NC]</p>
<p>Handy for anyone updating a site from static htm (you could use .html, or .htm(.*), .htm?, etc) to dynamic php pages; requests to the old pages are automatically rewritten to our new urls. no one notices a thing, visitors and search engines can access your content either way. leave the rule in; as an added bonus, this enables us to easily split php code and its included html structures into two separate files, a nice idea; makes editing and updating a breeze. The [NC] part at the end means &#8220;No Case&#8221;, or &#8220;case-insensitive&#8221;; more on the switches, later.</p>
<p>Folks can link to whatever.htm or whatever.php, but they always get whatever.php in their browser, and this works even if whatever.htm doesn&#8217;t exist! But I&#8217;m straying..</p>
<p>As it stands, it&#8217;s a bit tricky; folks will still have whatever.htm in their browser address bar, and will still keep bookmarking your old .htm URL&#8217;s. Search engines, too, will keep on indexing your links as .htm, some have even argued that serving up the same content from two different places could have you penalized by the search engines. This may or not bother you, but if it does, mod_rewrite can do some more magic..</p>
<p>this will do a &#8220;real&#8221; external redirection:</p>
<p>Options +FollowSymlinks<br />
RewriteEngine on<br />
RewriteRule ^(.+)\.htm$ http://mysite/$1.php [R,NC]</p>
<p>This time we instruct mod_rewrite to do a proper external rewrite, aka, &#8220;redirection&#8221;. Now, instead of just background rewriting on-the-fly, the user&#8217;s browser is physically redirected to a new URI, and whatever.php appears in their browser&#8217;s address bar &#8211; search engines and other spidering entities will automatically update their links to the .php versions; everyone wins. You can take your time with the updating, too.</p>
<p>Note: if you use [R] alone, it defaults to sending an HTTP &#8220;MOVED TEMPORARILY&#8221; redirection, aka, &#8220;302&#8243;. But you can send other codes, like so..</p>
<p>this performs the exact same as the previous example RewriteRule.</p>
<p>RewriteRule ^(.+)\.htm$ http://mysite/$1.php [R=302,NC]</p>
<p>Okay, I sent the exact same code, but I didn&#8217;t have to. For details of the many 30* response codes you can send, see here. Most people seem to want to send 301, aka, &#8220;MOVED PERMENENTLY&#8221;.</p>
<p>Note: if you add an &#8220;L&#8221; flag to the mix; meaning &#8220;Last Rule&#8221;, e.g. [R=302,NC,L]; Apache will stop processing rules for this request at that point, which may or may not be what you want. Either way, it&#8217;s useful to know.</p>
<h1>not-so-simple rewriting &#8230; flat links and more</h1>
<p>You may have noticed, the above examples use regular expression to match variables. What that simply means is.. match the part inside (.+) and use it to construct &#8220;$1&#8243; in the new URL. In other words, (.+) = $1 you could have multiple (.+) parts and for each, mod_rewrite automatically creates a matching $1, $2, $3, etc, in your target (aka. &#8216;substitution&#8217;) URL. This facility enables us to do all sorts of tricks, and the most common of those, is the creation of &#8220;flat links&#8221;..</p>
<p>Even a cute short link like http://mysite/grab?file=my.zip is too ugly for some people, and nothing less than a true old-school solid domain/path/flat/link will do. Fortunately, mod_rewrite makes it easy to convert URLs with query strings and multiple variables into exactly this, something like..</p>
<p>a more complex rewrite rule:</p>
<p>Options +FollowSymlinks<br />
RewriteEngine on<br />
RewriteRule ^files/([^/]+)/([^/]+).zip /download.php?section=$1&amp;file=$2 [NC]</p>
<p>would allow you to present this link as..</p>
<p>http://mysite/files/games/hoopy.zip</p>
<p>and in the background have that transparently translated, server-side, to..</p>
<p>http://mysite/download.php?section=games&#038;file=hoopy</p>
<p>which some script could process. You see, many search engines simply don&#8217;t follow our ?generated=links, so if you create generating pages, this is useful. However, it&#8217;s only the dumb search engines that can&#8217;t handle these kinds of links; we have to ask ourselves.. do we really want to be listed by the dumb search engines? Google will handle a good few parameters in your URL without any problems, and the (hungry hungry) msn-bot stops at nothing to get that page, sometimes again and again and again…</p>
<p>I personally feel it&#8217;s the search engines that should strive to keep up with modern web technologies, in other words; we shouldn&#8217;t have to dumb-down for them. But that&#8217;s just my opinion. Many users will prefer /files/games/hoopy.zip to /download.php?section=games&amp;file=hoopy but I don&#8217;t mind either way. As someone pointed out to me recently, presenting links as standard/flat/paths means you&#8217;re less likely to get folks doing typos in typed URL&#8217;s, so something like..</p>
<p>an even more complex rewrite rule:</p>
<p>Options +FollowSymlinks<br />
RewriteEngine on<br />
RewriteRule ^blog/([0-9]+)-([a-z]+) http://mysite/blog/index.php?archive=$1-$2 [NC]</p>
<p>Here&#8217;s the very basics of regexp (expanded from the apache mod_rewrite documentation)..</p>
<p>Escaping:</p>
<p>\char escape that particular char</p>
<p>For instance to specify special characters.. [].()\ etc.</p>
<p>Text:</p>
<p>.             Any single character  (on its own = the entire URI)<br />
[chars]       Character class: One of following chars<br />
[^chars]      Character class: None of following chars<br />
text1|text2   Alternative: text1 or text2 (i.e. &#8220;or&#8221;)</p>
<p>e.g. [^/] matches any character except /<br />
(foo|bar)\.html matches foo.html and bar.html</p>
<p>Quantifiers:</p>
<p>? 0 or 1 of the preceding text<br />
* 0 or N of the preceding text  (hungry)<br />
+ 1 or N of the preceding text</p>
<p>e.g. (.+)\.html? matches foo.htm and foo.html<br />
(foo)?bar\.html matches bar.html and foobar.html</p>
<p>Grouping:</p>
<p>(text)  Grouping of text</p>
<p>Either to set the borders of an alternative or<br />
for making backreferences where the nth group can<br />
be used on the target of a RewriteRule with $n</p>
<p>e.g.  ^(.*)\.html foo.php?bar=$1</p>
<p>Anchors:</p>
<p>^    Start of line anchor<br />
$    End   of line anchor</p>
<p>An anchor explicitly states that the character right next to it MUST<br />
be either the very first character (&#8220;^&#8221;), or the very last character (&#8220;$&#8221;)<br />
of the URI string to match against the pattern, e.g..</p>
<p>^foo(.*) matches foo and foobar but not eggfoo<br />
(.*)l$ matches fool and cool, but not foo</p>
<p>..<br />
.<br />
.<br />
.<br />
Hope you enjoy this, I guess it help you to build your rewriting concepts  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />Posted in redirecting and rewriting Tagged: beginning rewriting, complex rewriting, external redirection, mod_rewrite, simple rewriting <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=74&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/redirecting_and_rewriting_through_htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Hide and deny files with htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/hide-and-deny-files-with-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/hide-and-deny-files-with-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 04:47:54 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Hide and deny files through htaccess]]></category>
		<category><![CDATA[deny files]]></category>
		<category><![CDATA[FilesMatch]]></category>
		<category><![CDATA[Hide files]]></category>
		<category><![CDATA[php flags]]></category>
		<category><![CDATA[php_value]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=71</guid>
		<description><![CDATA[Hide and deny files using htaccess Do you remember I mentioned that any file beginning with .ht is invisible? ..&#8221;almost every web server in the world is configured to ignore them, by default&#8221; and that is, of course, because .ht_anything files generally have server directives and passwords and stuff in them, most servers will have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=71&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Hide and deny files using htaccess</h2>
<p>Do you remember I mentioned that any file beginning with .ht is invisible? ..&#8221;almost every web server in the world is configured to ignore them, by default&#8221; and that is, of course, because .ht_anything files generally have server directives and passwords and stuff in them, <em>most</em> servers will have something like this in their main configuration..</p>
<blockquote>
<div>
<div><strong>Standard setting..<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</strong></div>
<div>&lt;Files ~ &#8220;^\.ht&#8221;&gt;<br />
Order allow,deny<br />
Deny from all<br />
Satisfy All<br />
&lt;/Files&gt;</div>
</div>
</blockquote>
<p>which instructs the server to deny access to any file beginning with .ht, effectively protecting our .htaccess and other files. The &#8220;.&#8221; at the start prevents them being displayed in an index, and the .ht prevents them being accessed. This version..</p>
<blockquote>
<div>
<div><strong>ignore what you want</strong></div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&lt;Files ~ &#8220;^.*\.([Ll][Oo][Gg])&#8221;&gt;<br />
Order allow,deny<br />
Deny from all<br />
Satisfy All<br />
&lt;/Files&gt;</div>
</div>
</blockquote>
<p>tells the server to deny access to *.log files. You can insert multiple file types into each rule, separating them with a pipe &#8220;|&#8221;, and you can insert multiple blocks into your .htaccess file, too. I find it convenient to put all the files starting with a dot into one, and the files with denied extensions into another, something like this..</p>
<blockquote>
<div>
<div>the whole lot</div>
<div># deny all .htaccess, .DS_Store $hî†é and ._* (resource fork) files<br />
&lt;Files ~ &#8220;^\.([Hh][Tt]|[Dd][Ss]_[Ss]|[_])&#8221;&gt;<br />
Order allow,deny<br />
Deny from all<br />
Satisfy All<br />
&lt;/Files&gt;</p>
<p># deny access to all .log and .comment files<br />
&lt;Files ~ &#8220;^.*\.([Ll][Oo][Gg]|[cC][oO][mM][mM][eE][nN][tT])&#8221;&gt;<br />
Order allow,deny<br />
Deny from all<br />
Satisfy All<br />
&lt;/Files&gt;</p></div>
</div>
</blockquote>
<p>would cover all  ._* resource fork files, .DS_Store files (which the Mac <a title="a bit like 'explorer' on windows, but the finder is the original&gt;.">Finder</a> creates <em>all over the place</em>) *.log files, *.comment files and of course, our .ht* files. You can add whatever file types you need to protect from direct access. I think it&#8217;s clear now why the file is called &#8220;.htaccess&#8221;.</p>
<h2>&lt;FilesMatch&gt;</h2>
<p>These days, using <tt>&lt;FilesMatch&gt;</tt> is preferred over <tt>&lt;Files&gt;</tt>, mainly because you can use regular expression in the conditions (very handy), produce clean, more readable code. Here&#8217;s an example. which I use for my php-generated style sheets..</p>
<blockquote>
<div>
<div>parse file.css and file.style with the php machine..</div>
<div># handler for phpsuexec..<br />
&lt;FilesMatch &#8220;\.(css|style)$&#8221;&gt;<br />
SetHandler application/x-httpd-php<br />
&lt;/FilesMatch&gt;</div>
</div>
</blockquote>
<p>Any files with a <tt>*.css</tt> or <tt>*.style</tt> extension will now be handled by php, rather than simply served up by Apache. And because you can use regexp, you could do stuff like <tt>&lt;FilesMatch "\.s?html$"&gt;</tt>, which is handy. Any <tt>&lt;Files&gt;</tt> statements you come across can be advantageously replaced by <tt>&lt;FilesMatch&gt;</tt> statements. Good to know.</p>
<h2>More stuff..</h2>
<p>At the end of my .htaccess files, there always seems to be a section of &#8220;stuff&#8221;; miscellaneous commands, mainly php flags and switches; so it seems logical to finish up the page with a wee selection of those..</p>
<blockquote>
<div>
<div>php flags, switches and other stuff..</div>
<div># let&#8217;s enable php (non-cgi, aka. &#8216;module&#8217;) for <em>EVERYTHING</em>..&#8217;<br />
AddType application/x-httpd-php5 .htm .html .php .blog .comment .inc</p>
<p># better yet..<br />
AddHandler php5-script .php</p>
<p># legacy php4 version..&#8217;<br />
AddType application/x-httpd-php .htm .html .php .blog .comment .inc</p>
<p># don&#8217;t even think about setting this to &#8216;on&#8217;<br />
<a id="help-register_globals" title="enable this to probably break your site's security">php_value register_globals off</a></p>
<p># no session id&#8217;s in the URL PULEEZE!<br />
php_value session.use_trans_sid 0<br />
# should be the same as..<br />
php_flag session.use_trans_sid off<br />
# using both should also work fine!</p>
<p># php error logs..<br />
php_flag display_errors off<br />
php_flag log_errors on<br />
<a id="help-track_errors" title="if enabled, the last error message is available in the variable $php_errormsg">php_value track_errors on</a><br />
php_value error_log /home/cor/errors/phperr.log</p>
<p># if you like to collect interesting php system shell access and web hack scripts<br />
# get yourself a SECURE upload facility, and just let the script-kiddies come …<br />
# in no time you will have a huge selection of fascinating code. If you want folk to<br />
# also upload zips and stuff, you might want to increase the upload capacities..<br />
php_value upload_max_filesize 12M<br />
php_value post_max_size 12M</p>
<p># php 5 only, afaik. handy when your server isn&#8217;t where YOU are.<br />
php_value date.timezone Europe/Aberdeen<br />
# actually, Europe/Aberdeen isn&#8217;t a valid php timezone, so that won&#8217;t work.<br />
# I recommend you check the php manual for this function, because many crazy places ARE!</p></div>
</div>
</blockquote>
<p>Note: For most of the flags I&#8217;ve tested, you can use <tt>on</tt>/<tt>off</tt> and <tt>true</tt>/<tt>false</tt> interchangeably, as well as <tt>0</tt>/<tt>1</tt>, also <tt>php_value</tt> and <tt>php_flag</tt> can be switched around while things continue to work as expected! I guess, logically, booleans should always be <tt>php_flag</tt>, and values, <tt>php_value</tt>; but suffice to say, if some php erm, <em>directive</em> isn&#8217;t working, these would all be good things to fiddle with!</p>
<p>Of course, the php manual explains all. The bottom line is; both will work fine, but if you use the wrong type in .htaccess, say, set a <tt>php_flag</tt> using <tt>php_value</tt>, a php <tt>ini_get()</tt> command, for instance, would return <tt>true</tt>, even though you had set the value to <tt>off</tt>, because it reads <tt>off</tt> value as a <em>string</em>, which of course evaluates to not-zero, i.e. 1, or &#8220;true&#8221;. If you don&#8217;t rely on <tt>get_ini()</tt>, or similar, it&#8217;s not a problem, though clearly it&#8217;s better to get it right from the start. By the way; <a id="link-trick-examples" title="Okay, two!">one</a> of the values above is incorrectly set. Did you spot it?</p>
<p>Most php settings, you can override inside your actual scripts, but I do find it handy to be able to set defaults for a folder, or an entire site, using .htaccess.</p>
<p>Enjoyyyyyyy</p>
<br />Posted in Hide and deny files through htaccess Tagged: deny files, FilesMatch, Hide files, php flags, php_value <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=71&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/hide-and-deny-files-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Save bandwidth with .htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/save-bandwidth-with-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/save-bandwidth-with-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 04:43:33 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Save bandwidth with .htaccess]]></category>
		<category><![CDATA[saving bandwidth]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=69</guid>
		<description><![CDATA[Save bandwidth using .htaccess If you pay for your bandwidth, this wee line could save you hard cash.. save me hard cash! and help the internet! &#60;ifModule mod_php4.c&#62; php_value zlib.output_compression 16386 &#60;/ifModule&#62; All it does is enables PHP&#8217;s built-in transparent zlib compression. This will half your bandwidth usage in one stroke, more than that, in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=69&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Save bandwidth using .htaccess</h2>
<p>If you pay for your bandwidth, this wee line could save you hard <strong>cash</strong>..</p>
<blockquote>
<div>
<div>save me hard cash! and help the internet!</div>
<div>&lt;ifModule mod_php4.c&gt;<br />
php_value zlib.output_compression 16386<br />
&lt;/ifModule&gt;</div>
</div>
</blockquote>
<p>All it does is enables PHP&#8217;s built-in transparent zlib compression. This will half your bandwidth usage in one stroke, more than that, in fact. Of course it only works with data being output by the PHP module, but if you design your pages with this in mind, you can use php echo statements, or better yet, php &#8220;includes&#8221; for your plain html output and just compress <em>everything!</em> Remember, if you run phpsuexec, you&#8217;ll need to put php directives in a local <tt>php.ini</tt> file, not .htaccess.</p>
<br />Posted in Save bandwidth with .htaccess Tagged: saving bandwidth <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=69&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/save-bandwidth-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>500 error</title>
		<link>http://parmendra.wordpress.com/2009/07/10/500-error/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/500-error/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 04:40:55 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[500 error handling through htaccess]]></category>
		<category><![CDATA[500 error]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=67</guid>
		<description><![CDATA[500 Error If you add something that the server doesn&#8217;t understand or support, you will get a 500 error page, aka.. &#8220;the server did a boo-boo&#8221;. Even directives that work perfectly on your test server at home may fail dramatically at your real site. In fact this is a great way to find out if [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=67&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>500 Error</h2>
<p>If you add something that the server doesn&#8217;t understand or support, you will get a 500 error page, aka.. &#8220;the server did a boo-boo&#8221;. Even directives that work perfectly on your test server at home may fail dramatically at your real site. In fact this is a great way to find out if .htaccess files are enabled on your site; create one, put some gibberish in it, and load a page in that folder, wait for the 500 error. if there isn&#8217;t one, probably they are <em>not</em> enabled.</p>
<p>If they are, we need a way to safely do live-testing without bringing the whole site to a 500 standstill.</p>
<p>Fortunately, in much the same way as we used the <tt>&lt;Limit&gt;</tt> tag above, we can create <em>conditional</em> directives, things which will only come into effect if <em>certain conditions</em> are true. The most useful of these is the &#8220;ifModule&#8221; condition, which goes something like this..</p>
<blockquote>
<div>
<div>only if PHP is loaded, will this directive have any effect (switch the 4 for a 5 if using php5)</div>
<div>&lt;ifModule mod_php4.c&gt;<br />
php_value default_charset utf-8<br />
&lt;/ifModule&gt;</div>
</div>
</blockquote>
<p>..which placed in your master .htaccess file, that would set the default character encoding of your entire site to utf-8 (a good idea!), at least, anything output by PHP. If the PHP4<sup><tt>**</tt></sup> module isn&#8217;t running on the server, the above .htaccess directive will do exactly nothing; Apache just ignores it. As well as proofing us against knocking the server into 500 mode, this also makes our .htaccess directives that wee bit more portable. Of course, if your syntax is messed-up, no amount of if-module-ing is going to prevent a error of some kind, all the more reason to practice this stuff on a local test server.</p>
<blockquote>
<div>
<div><tt>**</tt> note: if you are using php5, you would obviously instead use <tt>&lt;ifModule mod_php5.c&gt;</tt>.</div>
</div>
</blockquote>
<br />Posted in 500 error handling through htaccess Tagged: 500 error <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=67&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/500-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Password protected directories</title>
		<link>http://parmendra.wordpress.com/2009/07/10/password-protected-directories/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/password-protected-directories/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 04:37:51 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Password protected directories through htaccess]]></category>
		<category><![CDATA[Password protected directories]]></category>
		<category><![CDATA[remote user]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=64</guid>
		<description><![CDATA[Password protected directories.. using htaccess file The next most obvious use for our .htaccess files is to allow access to only specific users, or user groups, in other words; password protected folders. a simple authorisation mechanism might look something like this.. a simple sample .htaccess file for password protection: &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; AuthType Basic AuthName &#8220;restricted area&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=64&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Password protected directories.. using htaccess file</h2>
<p>The next most obvious use for our .htaccess files is to allow access to only specific users, or user groups, in other words; password protected folders. a simple authorisation mechanism might look something like this..</p>
<blockquote>
<div>
<div><strong>a simple sample .htaccess file for password protection:</strong></div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
AuthType Basic<br />
AuthName &#8220;restricted area&#8221;<br />
AuthUserFile /usr/local/var/www/html/.htpasses<br />
require valid-user</div>
</div>
</blockquote>
<p>You can use this same mechanism to limit only <em>certain kinds</em> of requests, too..</p>
<blockquote>
<div>
<div><strong>only valid users can POST in here, anyone can GET, PUT, etc:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</strong></div>
<div>AuthType Basic<br />
AuthName &#8220;restricted area&#8221;<br />
AuthUserFile /usr/local/var/www/html/.htpasses<br />
&lt;Limit POST&gt;<br />
require valid-user<br />
&lt;/Limit&gt;</div>
</div>
</blockquote>
<p>You can find loads of <a title="apache docs - essential viewing (opens in a new window - apple-click (shift-click on peecees) for a new tab instead)" href="http://httpd.apache.org/docs/howto/auth.html">online examples</a> of how to setup authorization using .htaccess, and so long as you have a <em>real</em> user (or create one, in this case, &#8216;jimmy&#8217;) with a <em>real</em> password (you will be prompted for this, twice) in a <em>real</em> password file (the <tt>-c</tt> switch will create it)..</p>
<p><tt>htpasswd -c /usr/local/var/www/html/.htpasses parmendra</tt></p>
<p>..the above will work just fine. <tt>htpasswd</tt> is a tool that comes free with Apache, specifically for making and updating password files, check it out. The windows version is the same; only the file path needs to be changed; to wherever you want to put the password file.</p>
<p><strong>Note:</strong> if the Apache <tt>bin/</tt> folder isn&#8217;t in your PATH, you will need to <a id="help-command-cd" title="cd: change directory. a fairly universal computer command to move the working folder to somewhere else"><tt>cd</tt></a> into that directory before performing the command. Also note: You can use forward and back-slashes interchangeably with Apache/php on Windows, so this would work just fine..</p>
<p><tt>htpasswd -c c:/unix/usr/local/Apache2/conf/.htpasses parmendra</tt></p>
<p>Relative paths are fine too; assuming you were inside the <tt>bin/</tt> directory of our fictional Apache install, the following would do exactly the same as the above..</p>
<p><tt>htpasswd -c ../conf/.htpasses parmendra</tt></p>
<p>Naming the password file <tt>.htpasses</tt> is a habit from when I had to keep that file inside the web site itself, and as web servers are configured to ignore files beginning with <tt>.ht</tt>, they too, remain hidden. If you keep your password file <em>outside</em> the web root (a better idea), then you can call it whatever you like, but the <tt>.ht_something</tt> habit is a good one to keep, even inside the web tree, it is secure enough for our <em>basic</em> purpose..</p>
<p>Once they are logged in, you can access the <tt>remote_user</tt> environmental variable, and do stuff with it..</p>
<blockquote>
<div id="rewrite-preview">
<div>the <tt>remote_user</tt> variable is now available..</div>
<div>RewriteEngine on<br />
RewriteCond %{remote_user} !^$ [nc]<br />
RewriteRule ^(.*)$ /users/%{remote_user}/$1</div>
</div>
</blockquote>
<br />Posted in Password protected directories through htaccess Tagged: Password protected directories, remote user <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=64&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/password-protected-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom error documents</title>
		<link>http://parmendra.wordpress.com/2009/07/10/custom-error-documents/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/custom-error-documents/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 04:26:50 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Custom error documents]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=62</guid>
		<description><![CDATA[Custom error documents by htaccess file I guess I should briefly mention that .htaccess is where most folk configure their error documents. Usually with sommething like this.. the usual method. the &#8220;err&#8221; folder (with the custom pages) is in the root &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- # custom error documents ErrorDocument 401 /err/401.php ErrorDocument 403 /err/403.php ErrorDocument 404 /err/404.php [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=62&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Custom error documents by htaccess file</h2>
<p>I guess I should briefly mention that .htaccess is where most folk configure their error documents. Usually with sommething like this..</p>
<blockquote>
<div>
<div><strong>the usual method. the &#8220;err&#8221; folder (with the custom pages) is in the root<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</strong></div>
<div># custom error documents<br />
ErrorDocument 401 /err/401.php<br />
ErrorDocument 403 /err/403.php<br />
ErrorDocument 404 /err/404.php<br />
ErrorDocument 500 /err/500.php</div>
</div>
</blockquote>
<p>You can also specify external URLs, though this can be problematic, and is best avoided. One quick and simple method is to specify the text in the directive itself, you can even use HTML (though there is probably a limit to how much HTML you can squeeze onto one line). Remember, for Apache 1; begin with a <strong>&#8220;</strong>, but DO NOT end with one. For Apache 2, you can put a second quote at the end, as normal.</p>
<blockquote>
<div>
<div><strong>measure twice, quote once..</strong></div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
# quick custom error &#8220;document&#8221;..<br />
ErrorDocument 404 &#8220;&lt;html&gt;&lt;head&gt;&lt;title&gt;NO!&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h2&gt;&lt;tt&gt;There is nothing here.. go away quickly!&lt;/tt&gt;&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;</div>
</div>
</blockquote>
<p>Using a custom error document is a Very Good Idea, and will give you a second chance at your almost-lost visitors.</p>
<br />Posted in Custom error documents Tagged: Custom error documents <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=62&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/custom-error-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Control access through htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/10/control-access-through-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/control-access-through-htaccess/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 04:17:09 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Control access through htaccess]]></category>
		<category><![CDATA[ban IP]]></category>
		<category><![CDATA[Control access]]></category>
		<category><![CDATA[NO ENTRY outside of the LAN]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=60</guid>
		<description><![CDATA[Control access using htaccess file .htaccess is most often used to restrict or deny access to individual files and folders. A typical example would be an &#8220;includes&#8221; folder. Your site&#8217;s pages can call these included scripts all they like, but you don&#8217;t want users accessing these files directly, over the web. In that case you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=60&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Control access using htaccess file</h2>
<p>.htaccess is most often used to restrict or deny access to individual files and folders. A typical example would be an &#8220;includes&#8221; folder. Your site&#8217;s pages can call these included scripts all they like, but you don&#8217;t want users accessing these files directly, over the web. In that case you would drop an .htaccess file in the includes folder with content something like this..</p>
<blockquote>
<div>
<div>NO ENTRY!</div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# no one gets in here!<br />
deny from all</div>
</div>
</blockquote>
<p>which would deny ALL direct access to ANY files in that folder. You can be more specific with your conditions, for instance limiting access to a particular IP range, here&#8217;s a handy top-level rule for a local test server..</p>
<blockquote>
<div>
<div><strong>NO ENTRY outside of the LAN!</strong></div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
# no nasty crackers in here!<br />
order deny,allow<br />
deny from all<br />
allow from 192.168.0.0/24<br />
# this would do the same thing..<br />
#allow from 192.168.0</div>
</div>
</blockquote>
<p>Generally these sorts of requests would bounce off your firewall anyway, but on a live server (like my dev mirror sometimes is) they become useful for filtering out undesirable IP blocks, known risks, lots of things. By the way, in case you hadn&#8217;t spotted; lines beginning with &#8220;#&#8221; are ignored by Apache; handy for comments.</p>
<p>Sometimes, you will only want to ban one IP, perhaps some persistent robot that doesn&#8217;t play by the rules..</p>
<blockquote>
<div>
<div><strong>post user agent every fifth request only. hmmm. ban IP..</strong></div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# someone else giving the ruskies a bad name..<br />
order allow,deny<br />
deny from 83.222.23.219<br />
allow from all</div>
</div>
</blockquote>
<p>The usual rules for IP addresses apply, so you can use partial matches, ranges, and so on. Whatever, the user gets a 403 &#8220;access denied&#8221; error page in their client software (browser, usually), which certainly gets the message across.</p>
<br />Posted in Control access through htaccess Tagged: ban IP, Control access, NO ENTRY outside of the LAN <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=60&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/control-access-through-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Is .htaccess enabled?</title>
		<link>http://parmendra.wordpress.com/2009/07/10/is-htaccess-enabled/</link>
		<comments>http://parmendra.wordpress.com/2009/07/10/is-htaccess-enabled/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 03:54:13 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Is .htaccess enabled?]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=56</guid>
		<description><![CDATA[how to check that .htaccess is enabled? It&#8217;s unusual, but possible that .htaccess is not enabled on your site. If you are hosting it yourself, it&#8217;s easy enough to fix; open your httpd.conf in a text editor, and locate this &#60;Directory&#62; section.. Your DocumentRoot may be different, of course.. # This should be changed to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=56&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>how to check that .htaccess is enabled?</h2>
<p>It&#8217;s unusual, but possible that .htaccess is not enabled on your site. If you are hosting it yourself, it&#8217;s easy enough to fix; open your <tt>httpd.conf</tt> in a text editor, and locate this <tt>&lt;Directory&gt;</tt> section..</p>
<blockquote>
<div class="blockquote">
<div class="codetop"><strong><em>Your </em><tt> DocumentRoot</tt> may be different, of course.. </strong></div>
<div class="codeblock"><strong> # This should be changed to whatever you set DocumentRoot to.</strong></p>
<p><strong>#</strong></p>
<p><strong>&lt;Directory &#8220;/var/www/htdocs&#8221;&gt;</strong></p>
<p><strong># </strong></div>
</div>
</blockquote>
<p>..locate the line that reads..</p>
<blockquote>
<div class="blockquote">
<div class="codeblock"><strong>AllowOverride None </strong></div>
</div>
</blockquote>
<p>..and change it to..</p>
<blockquote>
<div class="blockquote">
<div class="codeblock"><strong>AllowOverride All </strong></div>
</div>
</blockquote>
<p>Restart Apache. Now .htaccess will work. You can also make this change inside a virtual host, which would normally be preferable.</p>
<p>If your site is hosted with someone else, check your control panel (Plesk. CPanel, etc.) to see if you can enable it there, and if not, contact your hosting admins. Perhaps they don&#8217;t allow this. In which case, switch to a better web host.</p>
<br />Posted in Is .htaccess enabled?  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=56&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/10/is-htaccess-enabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>What are .htaccess files anyway?</title>
		<link>http://parmendra.wordpress.com/2009/07/09/what-are-htaccess-files-anyway/</link>
		<comments>http://parmendra.wordpress.com/2009/07/09/what-are-htaccess-files-anyway/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 04:47:46 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[What are .htaccess files anyway?]]></category>
		<category><![CDATA[htaccess file]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[server directives]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=52</guid>
		<description><![CDATA[What are .htaccess files anyway, how one can create? Simply put, they are invisible plain text files where one can store server directives. Server directives are anything you might put in an Apache config file (httpd.conf) or even a php.ini**, but unlike those &#8220;master&#8221; directive files, these .htaccess directives apply only to the folder in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=52&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>What <em>are</em> .htaccess files anyway, how one can create?</h2>
<p>Simply put, they are invisible plain text files where one can store <strong>server directives</strong>. Server directives are anything you might put in an Apache config file (<tt>httpd.conf</tt>) or even a <tt>php.ini</tt>**, but unlike those &#8220;master&#8221; directive files, these .htaccess directives apply only to the folder in which the .htaccess file resides, <em>and all the folders inside</em>.</p>
<p>This ability to plant .htaccess files in any directory of our site allows us to set up a finely-grained tree of server directives, each subfolder inheriting properties from its parent, whilst at the same time adding to, or over-riding certain directives with its own .htaccess file. For instance, you could use .htacces to enable indexes all over your site, and then deny indexing in only certain subdirectories, <em>or</em> deny index listings site-wide, and <em>allow</em> indexing in certain subdirectories. One line in the .htaccess file in your root and your whole site is altered. From here on, I&#8217;ll probably refer to the main .htaccess in the root of your website as &#8220;the master .htaccess file&#8221;, or &#8220;main&#8221; .htaccess file.</p>
<p>There&#8217;s a small performance penalty for all this .htaccess file checking, but not noticeable, and you&#8217;ll find most of the time <em>it&#8217;s just on</em> and there&#8217;s nothing you can do about it anyway, so let&#8217;s make the most of it..</p>
<p>** Your main <tt>php.ini</tt>, that is, unless you are running under phpsuexec, in which case the directives would go inside <em>individual</em> <tt>php.ini</tt> files</p>
<br />Posted in What are .htaccess files anyway? Tagged: htaccess file, httpd.conf, php.ini, server directives <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=52&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/09/what-are-htaccess-files-anyway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>What can I do with htaccess files ?</title>
		<link>http://parmendra.wordpress.com/2009/07/03/what-can-i-do-with-htaccess-files/</link>
		<comments>http://parmendra.wordpress.com/2009/07/03/what-can-i-do-with-htaccess-files/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 04:54:17 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[What can I do with htaccess files ?]]></category>
		<category><![CDATA[500 error]]></category>
		<category><![CDATA[Control access]]></category>
		<category><![CDATA[Custom error documents]]></category>
		<category><![CDATA[Hide and deny files]]></category>
		<category><![CDATA[Password protected directories]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=47</guid>
		<description><![CDATA[What can I do with htaccess files? Almost any directive that you can put inside an httpd.conf file will also function perfectly inside an .htaccess file. Unsurprisingly, the most common use of .htaccess is to.. Control access Custom error documents Password protected directories Get better protection 500 error custom directory index files Save bandwidth with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=47&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>What can I do with htaccess files?</h2>
<p>Almost any directive that you can put inside an <tt>httpd.conf</tt> file will also function perfectly inside an .htaccess file. Unsurprisingly, the most common use of .htaccess is to..</p>
<p><strong>Control access </strong><br />
<strong>Custom error documents </strong><br />
<strong> Password protected directories<br />
Get better protection</strong> <strong><br />
500 error<br />
custom directory index files<br />
Save bandwidth with .htaccess<br />
Hide and deny files</strong></p>
<br />Posted in What can I do with htaccess files ? Tagged: 500 error, Control access, Custom error documents, Hide and deny files, Password protected directories <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=47&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/03/what-can-i-do-with-htaccess-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Introduction to .htaccess</title>
		<link>http://parmendra.wordpress.com/2009/07/03/introduction-to-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/07/03/introduction-to-htaccess/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 04:40:41 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Url rewrite through htaccess]]></category>
		<category><![CDATA[htaccess intoduction]]></category>
		<category><![CDATA[htaccess uses]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[server directives]]></category>
		<category><![CDATA[what is htaccess]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=43</guid>
		<description><![CDATA[htaccess file This work in constant progress is some collected wisdom, stuff I&#8217;ve learned on the topic of .htaccess hacking, commands I&#8217;ve used successfully in the past, on a variety of server setups, and in most cases still do. You may have to tweak the examples some to get the desired result, though, and a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=43&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>htaccess file</h2>
<p>This work in constant progress is some collected wisdom, stuff I&#8217;ve learned on the topic of .htaccess hacking, commands I&#8217;ve used successfully in the past, on a variety of server setups, and in most cases still do. You may have to tweak the examples some to get the desired result, though, and a reliable test server is a powerful ally, preferably one with a very similar setup to your &#8220;live&#8221; server. Okay, to begin..</p>
<p><strong>..a win32 Apache mirror of cor </strong></p>
<p><strong><img class="alignnone size-full wp-image-44" title="clip_image002" src="http://parmendra.files.wordpress.com/2009/07/clip_image002.gif?w=614" alt="clip_image002"   /><br />
</strong></p>
<p><strong><em>.htaccess files are invisible</em></strong></p>
<p>There&#8217;s a good reason why you won&#8217;t see .htaccess files on the web; almost every web server in the world is configured to ignore them, by default. Same goes for most operating systems. Mainly it&#8217;s the dot &#8220;.&#8221; at the start, you see?</p>
<p>If you <em>don&#8217;t</em> see, you&#8217;ll need to disable your operating system&#8217;s invisible file functions, or use a text editor that allows you to open hidden files, something like bbedit on the Mac platform. On windows, showing invisibles in explorer should allow any text editor to open them, and most decent editors to <em>save</em> them too*_*. Linux dudes know how to find them without any help from me.</p>
<p><img class="alignnone size-full wp-image-45" title="clip_image004" src="http://parmendra.files.wordpress.com/2009/07/clip_image004.jpg?w=614" alt="clip_image004"   /><br />
<strong><br />
that same folder, as seen from Mac OS X</strong><br />
In both images, the operating system has been instructed to <em>display</em> invisible files. ugly, but necessary sometimes. You will also need to instruct your ftp client to do the same.</p>
<p>By the way; the windows screencap is more recent than the mac one, moved files are likely being handled by my clever 404 script.</p>
<p>** even notepad can save files beginning with a dot, if you put double-quotes around the name when you save it; i.e.. &#8220;.htaccess&#8221;. You can also use your ftp client to rename files beginning with a dot, even on your local filesystem; works great in FileZilla.</p>
<br />Posted in Url rewrite through htaccess Tagged: htaccess intoduction, htaccess uses, httpd.conf, server directives, what is htaccess <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=43&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/03/introduction-to-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>

		<media:content url="http://parmendra.files.wordpress.com/2009/07/clip_image002.gif" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://parmendra.files.wordpress.com/2009/07/clip_image004.jpg" medium="image">
			<media:title type="html">clip_image004</media:title>
		</media:content>
	</item>
		<item>
		<title>Php Regular expression basic tutorial</title>
		<link>http://parmendra.wordpress.com/2009/07/01/php-regular-expression-basic-tutorial/</link>
		<comments>http://parmendra.wordpress.com/2009/07/01/php-regular-expression-basic-tutorial/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 10:12:40 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Php regular expression]]></category>
		<category><![CDATA[ereg]]></category>
		<category><![CDATA[eregi]]></category>
		<category><![CDATA[Perl Style Delimiters]]></category>
		<category><![CDATA[preg_match]]></category>
		<category><![CDATA[preg_match_all]]></category>
		<category><![CDATA[preg_split]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=36</guid>
		<description><![CDATA[Php Regular expression basic tutorial Regular Expressions Tutorial Basic Syntax of Regular Expressions (as from PHPBuilder.com) First of all, let&#8217;s take a look at two special symbols: &#8216;^&#8217; and &#8216;$&#8217;. What they do is indicate the start and the end of a string, respectively, like this: &#8220;^The&#8221;: matches any string that starts with &#8220;The&#8221;; &#8220;of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=36&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Php Regular expression basic tutorial </h2>
<table border="0" width="200">
<tbody>
<tr>
<td>
<h1>Regular Expressions Tutorial</h1>
<h2>Basic Syntax of Regular</p>
<p>Expressions (as from <a href="http://www.phpbuilder.com/columns/dario19990616.php3">PHPBuilder.com</a>)</h2>
<p>First of all, let&#8217;s take a look at two special symbols: &#8216;^&#8217; and &#8216;$&#8217;.</p>
<p>What they do is indicate the<br />
start and the end of a string, respectively, like this:</p>
<p>&#8220;^The&#8221;: matches any string that starts with &#8220;The&#8221;;</p>
<p>&#8220;of despair$&#8221;: matches a string that ends in the substring &#8220;of despair&#8221;;</p>
<p>&#8220;^abc$&#8221;: a string that starts and ends with &#8220;abc&#8221; &#8212; that could only be &#8220;abc&#8221; itself!</p>
<p>&#8220;notice&#8221;: a string that has the text &#8220;notice&#8221; in it.</p>
<p>You can see that if you don&#8217;t use either of the two characters we mentioned,<br />
as in the last example,</p>
<p>you&#8217;re saying that the pattern may occur anywhere inside the string</p>
<p>&#8211; you&#8217;re not &#8220;hooking&#8221; it to any of the edges.</p>
<p>There are also the symbols &#8216;*&#8217;, &#8216;+&#8217;, and &#8216;?&#8217;, which denote the number<br />
of times a character or a sequence of characters may occur.</p>
<p>What they mean is: &#8220;zero or more&#8221;, &#8220;one or more&#8221;,<br />
and &#8220;zero or one.&#8221; Here are some examples:</p>
<p>&#8220;ab*&#8221;: matches a string that has an a followed by zero or<br />
more b&#8217;s (&#8220;a&#8221;, &#8220;ab&#8221;, &#8220;abbb&#8221;, etc.);</p>
<p>&#8220;ab+&#8221;: same, but there&#8217;s at least one b (&#8220;ab&#8221;, &#8220;abbb&#8221;, etc.);</p>
<p>&#8220;ab?&#8221;: there might be a b or not;</p>
<p>&#8220;a?b+$&#8221;: a possible a followed by one or more b&#8217;s ending a string.</p>
<p>You can also use bounds, which come inside braces<br />
and indicate ranges in the number of occurences:</p>
<p>&#8220;ab{2}&#8221;: matches a string that has an a followed by exactly two b&#8217;s (&#8220;abb&#8221;);</p>
<p>&#8220;ab{2,}&#8221;: there are at least two b&#8217;s (&#8220;abb&#8221;, &#8220;abbbb&#8221;, etc.);</p>
<p>&#8220;ab{3,5}&#8221;: from three to five b&#8217;s (&#8220;abbb&#8221;, &#8220;abbbb&#8221;, or &#8220;abbbbb&#8221;).</p>
<p>Note that you must always specify the first number of a range<br />
(i.e, &#8220;{0,2}&#8221;, not &#8220;{,2}&#8221;).</p>
<p>Also, as you might<br />
have noticed,</p>
<p>the symbols &#8216;*&#8217;, &#8216;+&#8217;, and &#8216;?&#8217; have the same effect as<br />
using the bounds &#8220;{0,}&#8221;, &#8220;{1,}&#8221;, and &#8220;{0,1}&#8221;,<br />
respectively.</p>
<p>Now, to quantify a sequence of characters, put them inside parentheses:</p>
<p>&#8220;a(bc)*&#8221;: matches a string that has an a followed<br />
by zero or more copies of the sequence &#8220;bc&#8221;;</p>
<p>&#8220;a(bc){1,5}&#8221;: one through five copies of &#8220;bc.&#8221;</p>
<p>There&#8217;s also the &#8216;|&#8217; symbol, which works as an OR operator:</p>
<p>&#8220;hi|hello&#8221;: matches a string that has either &#8220;hi&#8221; or &#8220;hello&#8221; in it;</p>
<p>&#8220;(b|cd)ef&#8221;: a string that has either &#8220;bef&#8221; or &#8220;cdef&#8221;;</p>
<p>&#8220;(a|b)*c&#8221;: a string that has a sequence of alternating a&#8217;s and b&#8217;s ending in a c;</p>
<p>A period (&#8216;.&#8217;) stands for any single character:</p>
<p>&#8220;a.[0-9]&#8220;:matches a string that has an a followed by one character and a digit;</p>
<p>&#8220;^.{3}$&#8221;: a string with exactly 3 characters.</p>
<p>Bracket expressions specify which characters<br />
are allowed in a single position of a string:</p>
<p>&#8220;[ab]&#8220;: matches a string that has either an a or a b (that&#8217;s the same as &#8220;a|b&#8221;);</p>
<p>&#8220;[a-d]&#8220;: a string that has lowercase letters &#8216;a&#8217;<br />
through &#8216;d&#8217; (that&#8217;s equal to &#8220;a|b|c|d&#8221; and even &#8220;[abcd]&#8220;);</p>
<p>&#8220;^[a-zA-Z]&#8220;: a string that starts with a letter;<br />
&#8220;[0-9]%&#8221;:</p>
<p>a string that has a single digit before a percent sign;</p>
<p>&#8220;,[a-zA-Z0-9]$&#8221;: a string that ends in a comma<br />
followed by an alphanumeric character.</p>
<p>You can also list which characters you</p>
<p>DON&#8217;T want &#8212; just use a &#8216;^&#8217; as the first symbol in a bracket</p>
<p>expression<br />
(i.e., &#8220;%[^a-zA-Z]%&#8221; matches a string with a</p>
<p>character that is not a letter between two percent signs).</p>
<p>In order to be taken literally,</p>
<p>you must escape the characters</p>
<p>&#8220;^.[$()|*+?{\" with a backslash ('\'),</p>
<p>as<br />
they have special meaning.</p>
<p>On top of that, you must escape the backslash character itself in PHP3 strings,</p>
<p>so,<br />
for instance, the regular expression "(\$|¥)[0-9]+&#8221; would have</p>
<p>the function call: ereg(&#8220;(\\$|¥)[0-9]+&#8221;, $str)</p>
<p>(what string does that validate?)</p>
<p><strong>Example 1.</strong></p>
<p>Examples of valid patterns</p>
<p>* /&lt;\/\w+&gt;/</p>
<p>* |(\d{3})-\d+|Sm</p>
<p>* /^(?i)php[34]/</p>
<p>* {^\s+(\s+)?$} <strong>Example 2.</strong></p>
<p>Examples of invalid patterns</p>
<p>* /href=&#8217;(.*)&#8217; &#8211; missing ending delimiter</p>
<p>* /\w+\s*\w+/J &#8211; unknown modifier &#8216;J&#8217;</p>
<p>* 1-\d3-\d3-\d4| &#8211; missing starting delimiter</p>
<h2>Some useful PHP Keywords</p>
<p>and their use  (<a href="http://us4.php.net/manual/en/index.php">php.net man pages</a>)</h2>
<h3><em>preg_split</em></h3>
<p>(PHP 3&gt;= 3.0.9, PHP 4 )</p>
<p>preg_split &#8212; Split string by a regular expression<br />
Description<br />
array preg_split</p>
<p>( string pattern, string subject [, int limit [, int flags]])</p>
<p>Returns an array containing substrings of subject split along</p>
<p>boundaries matched by pattern.</p>
<p>If limit is specified, then only substrings up to limit are returned,</p>
<p>and if limit is -1, it<br />
actually means &#8220;no limit&#8221;,</p>
<p>which is useful for specifying the flags.</p>
<p>flags can be any combination of</p>
<p>the following flags (combined with bitwise | operator):</p>
<p><strong>PREG_SPLIT_NO_EMPTY</strong> If this flag is set, only non-empty</p>
<p>pieces will be returned by preg_split().</p>
<p><strong>PREG_SPLIT_DELIM_CAPTURE</strong></p>
<p>If this flag is set,<br />
parenthesized expression in the delimiter pattern</p>
<p>will be captured and<br />
returned as well.<br />
This flag was added for 4.0.5.</p>
<p><strong>PREG_SPLIT_OFFSET_CAPTURE</strong></p>
<p>If this flag is set, for every occuring match the appendant</p>
<p>string offset will also be<br />
returned. Note that this changes</p>
<p>the return value in an array where every element is an</p>
<p>array consisting of the matched string at offset 0 and it&#8217;s string</p>
<p>offset into subject<br />
at offset 1.</p>
<p>This flag is available since PHP 4.3.0 .</p>
<pre><strong>Example 1. </strong>preg_split() example : Get the parts of a search string

&lt;?php
// split the phrase by any number of commas or space characters,
// which include " ", \r, \t, \n and \f
$keywords = preg_split ("/[\s,]+/", "hypertext
language, programming");
?&gt;

<strong>Example 2. </strong>Splitting a string into component characters

<!--mce:0-->
<!--mce:1-->

&lt;?php
$str = 'string';
$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
print_r($chars);
?&gt;

<strong>Example 3. </strong>Splitting a string into matches and their offsets

&lt;?php
$str = 'hypertext language programming';
$chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
print_r($chars);
?&gt;

will yield:

Array
(
    [0] =&gt; Array
        (
            [0] =&gt; hypertext
            [1] =&gt; 0
        )

    [1] =&gt; Array
        (
            [0] =&gt; language
            [1] =&gt; 10
        )

    [2] =&gt; Array
        (
            [0] =&gt; programming
            [1] =&gt; 19
        )

)</pre>
<pre><em>Note: Parameter flags was added in PHP 4 Beta 3.</em>
<h3><em>preg_match</em></h3>

(PHP 3&gt;= 3.0.9, PHP 4 )
preg_match -- Perform a regular expression match
Description
int preg_match ( string pattern, string subject [, array matches [, int flags]])

Searches subject for a match to the regular expression
given in pattern.

If matches is provided, then it is filled with
the results of search. $matches[0] will
contain the text that matched the full pattern,
 $matches[1] will have the text that matched
 the first captured parenthesized subpattern, and so on.

flags can be the following flag:

PREG_OFFSET_CAPTURE
    If this flag is set, for every occuring match the
        appendant string offset will also
	be returned. Note that this changes the return
        value in an array where every element
	is an array consisting of the matched string
        at offset 0 and it's string offset into
	subject at offset 1. This flag is available
        since PHP 4.3.0 .

The flags parameter is available since PHP 4.3.0 .

<em>preg_match()</em> returns the number of times pattern matches.
      That will be either 0 times
	(no match) or 1 time because preg_match() will stop
        searching after the first match.
<em>preg_match_all()</em> on the contrary will continue
       until it reaches the end of subject.
<em>preg_match()</em> returns FALSE if an error occured.

    Tip: Do not use preg_match() if you only want to check if
        one string is contained
	in another string. Use strpos() or strstr()
        instead as they will be faster.

<strong>Example 1.</strong> Find the string of text "php"

&lt;?php
// The "i" after the pattern delimiter indicates a
//case-insensitive search
if (preg_match ("/php/i", "PHP is the web scripting language of choice.")) {
    print "A match was found.";
} else {
    print "A match was not found.";
}
?&gt;

&lt;strong&gt;Example 2.&lt;/strong&gt; Find the word "web"

&lt;?php
/* The \b in the pattern indicates a word boundary, so only the distinct
 * word "web" is matched, and not a word partial like "webbing" or "cobweb" */
if (preg_match ("/\bweb\b/i", "PHP is the web scripting language of choice.")) {
    print "A match was found.";
} else {
    print "A match was not found.";
}

if (preg_match ("/\bweb\b/i", "PHP is the website scripting language of choice.")) {
    print "A match was found.";
} else {
    print "A match was not found.";
}
?&gt;

&lt;strong&gt;Example 3.&lt;/strong&gt; Getting the domain name out of a URL

&lt;?php
// get host name from URL
preg_match("/^(http:\/\/)?([^\/]+)/i",
    "http://www.php.net/index.html", $matches);
$host = $matches[2];

// get last two segments of host name
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
echo "domain name is: {$matches[0]}\n";
?&gt;

This example will produce:

domain name is: php.net

<!--mce:2-->
<!--mce:3-->
<h2>Perl Style Delimiters  (<a href="http://www.crazygrrl.com/weav/regex.php3">as from crazygrrl.com</a>)</h2>

When using Perl-style matching,
the pattern also has to be enclosed by special delimiters.
The default is the forward slash, though you can use others.
For example:</pre>
<pre>     /colou?r/</pre>
<pre>Usually you'll want to stick with the default,
but if you need to use the
forward slash a lot in the
actual pattern (especially if you're dealing with
pathnames) you might want to use something else:</pre>
<pre>     !/root/home/random!</pre>
<pre>To make a match case-insensitive,
all you need to do is append the option
i to the pattern:</pre>
<pre>     /colou?r/i</pre>
<pre>Perl-style functions support these extra
metacharacters (this is not a full
list):</pre>
<pre>\b A word boundary, the spot between word (\w)
and non-word (\W) characters.
     \B A non-word boundary.
     \d A single digit character.
     \D A single non-digit character.
     \n The newline character. (ASCII 10)
     \r The carriage return character. (ASCII 13)
     \s A single whitespace character.
     \S A single non-whitespace character.
     \t The tab character. (ASCII 9)
     \w A single word character - alphanumeric and underscore.
     \W A single non-word character.</pre>
<pre>Example:</pre>
<pre>     /\bhomer\b/</pre>
<pre>Have a donut, Homer no match
     A tale of homeric proportions! no match
     Do you think he can hit a homer? match</pre>
<pre>Corresponding to ereg() is preg_match(). Syntax:</pre>
<pre>     preg_match(pattern (string), target (string), optional_array);</pre>
<pre>Example:</pre>
<pre>     $pattern = "/\b(do(ugh)?nut)\b.*\b(Homer|Fred)\b/i";</pre>
<pre>$target = "Have a donut, Homer.";</pre>
<pre>if (preg_match($pattern, $target, $matches)) {</pre>
<pre> print("&lt;P&gt;Match: $reg[0]&lt;/P&gt;");
     print("&lt;P&gt;Pastry: $reg[1]&lt;/P&gt;");
     print("&lt;P&gt;Variant: $reg[2]&lt;/P&gt;");
     print("&lt;P&gt;Name: $reg[3]&lt;/P&gt;");
     }</pre>
<pre>else {
     print("No match.");
     }</pre>
<pre>Results:</pre>
<pre>     Match: donut, Homer</pre>
<pre>Pastry: donut</pre>
<pre>Variant: [blank because there was no "ugh"]</pre>
<pre>Name: Homer</pre>
<pre>     If you use the $target "Doughnut, Frederick?"
there will be no match,
	 since there has to be a word boundary after Fred.</pre>
<pre>but "Doughnut, fred?" will match since we've specified it to be
case-insensitive.</pre>
<pre><strong>Contributed code which is applicable (and very useful!)</strong>
<strong>mkr at binarywerks dot dk</strong>
<em>A (AFAIK) correct implementation of Ipv4 validation,
this one supports optional ranges
(CIDR notation) and it validates numbers from 0-255 only
in the address part, and 1-32
only after the /</em>

&lt;?

function valid_ipv4($ip_addr)
{
        $num="([0-9]|1?\d\d|2[0-4]\d|25[0-5])";
        $range="([1-9]|1\d|2\d|3[0-2])";

        if(preg_match("/^$num\.$num\.$num\.$num(\/$range)?$/",$ip_addr))
        {
                return 1;
        }

        return 0;
}

$ip_array[] = "127.0.0.1";
$ip_array[] = "127.0.0.256";
$ip_array[] = "127.0.0.1/36";
$ip_array[] = "127.0.0.1/1";

foreach ($ip_array as $ip_addr)
{
        if(valid_ipv4($ip_addr))
        {
                echo "$ip_addr is valid&lt;BR&gt;\n";
        }
        else
        {
                echo "$ip_addr is NOT valid&lt;BR&gt;\n";
        }
}

?&gt;

<strong>plenque at hotmail dot com</strong>
<em>I wrote a function that checks if a given regular expression
is valid. I think some of
you might find it useful. It changes the error_handler
 and restores it, I didn't find
any other way to do it.</em>

Function IsRegExp ($sREGEXP)
{
    $sPREVIOUSHANDLER = Set_Error_Handler ("TrapError");
    Preg_Match ($sREGEXP, "");
    Restore_Error_Handler ($sPREVIOUSHANDLER);
    Return !TrapError ();
}

Function TrapError ()
{
    Static $iERRORES;

    If (!Func_Num_Args ())
    {
        $iRETORNO = $iERRORES;
        $iERRORES = 0;
        Return $iRETORNO;
    }
    Else
    {
        $iERRORES++;
    }
}

<strong>PHP Get_title tag code which uses simple regex and nice
php string functions</strong>
(As from <a href="http://www.zend.com/codex.php?id=233&amp;single=1">Zend PHP</a>)

&lt;?php
function get_title_tag($chaine){
    $fp = fopen ($chaine, 'r');
    while (! feof ($fp)){
         $contenu .= fgets ($fp, 1024);
         if (stristr($contenu, '&lt;\title&gt;' )){
                 break;
                }
         }
    if (eregi("", $contenu, $out)) {
        return $out[1];
        }
    else{
        return false;
        }
    }
?&gt;

<strong>My Own 'Visitor Trac' code which uses regex XML parsing methods</strong>

&lt;?php
$referer = $_SERVER['HTTP_REFERER'];
$filename = $_SERVER[REMOTE_ADDR] . '.txt';
//print_r($_SERVER);
if (file_exists($filename)){
	$lastvisit = filectime($filename);
	$currentdate = date('U');
	$difference = round(($currentdate - $lastvisit)/84600);
	if ($difference &gt; 7)  {
		unlink($filename);
		$fp = fopen($filename, "a");
	}
	else $fp = fopen($filename, "a");
}
	else $fp = fopen($filename, "a");
if (!$_SERVER['HTTP_REFERER']) $url_test = 'http://dinki.mine.nu/weblog/';
else $url_test = $_SERVER['HTTP_REFERER'];
$new_title = return_title ($url_test);
//print $new_title;
$new_name = stripslashes("&lt;beg&gt;$new_title\n");
$new_URL = stripslashes("&lt;beg&gt;$referer\n");
fwrite($fp,$new_URL);
fwrite($fp,$new_name);
fclose($fp);

$fp = fopen($filename, "r");
$file = implode('', file ($filename));
$foo = preg_split("/&lt;beg&gt;/",$file);
$number = count($foo);
//print $number;
if ($number &gt; 11) {
	fclose($fp);
	$fp = fopen($filename, "w");
	$count = $number - 10;
	while ($count &lt; $number)  {
		$print1 = $foo[$count];
		$print2 = $foo[$count+1];
		print " &lt;img src = arrow.gif&gt; ";
		print "&lt;a href=$print1&gt;$print2&lt;/a&gt;"; //print $count;
		$count += 2;
		$new_name = stripslashes("&lt;beg&gt;$print2");
		$new_URL = stripslashes("&lt;beg&gt;$print1");
		fwrite($fp,$new_URL);
		fwrite($fp,$new_name);
	}
	fclose($fp);
}
//print_r($foo);
else  {
	$count = 1;
	while ($count &lt;= $number)  {
		$print1 = $foo[$count];
		$print2 = $foo[$count+1];
		print " &lt;img src = arrow.gif&gt; ";
		print "&lt;a href=$print1&gt;$print2&lt;/a&gt;"; //print $count;
		$count += 2;
		}
	fclose($fp);
	}

function return_title($url)  {
	print $filename." ".$difference;
		 $array = file ($url);
		  for ($i = 0; $i &lt; count($array); $i++)
		  {
			if (preg_match("/&lt;title&gt;(.*)&lt;\/title&gt;/i",$array[$i], $tag_contents))  {
				$title = $tag_contents[1];
				$title = strip_tags($title);
				}
		  }
		  return $title;
	}

?&gt;</pre>
</td>
</tr>
<tr>
<td></td>
</tr>
</tbody>
</table>
<br />Posted in Php regular expression Tagged: ereg, eregi, Perl Style Delimiters, Php regular expression, preg_match, preg_match_all, preg_split, regular expression <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=36&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/07/01/php-regular-expression-basic-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>php oops tutorial</title>
		<link>http://parmendra.wordpress.com/2009/06/29/php-oops-tutorial/</link>
		<comments>http://parmendra.wordpress.com/2009/06/29/php-oops-tutorial/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 09:47:46 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Simple Oops Concept]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[PHP object oriented tutorial]]></category>
		<category><![CDATA[PHP oops]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=30</guid>
		<description><![CDATA[php oops tutorial OOP stands for Object-Oriented Programming. It is a programming concept that caught on in the 1990&#8242;s. OOP focuses on &#8216;objects&#8217; which are, well, objects. They have certain characteristics, and can behave in certain ways. OOP programming has a few concepts that define it. One of the defining features we will start with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=30&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>php oops tutorial</h2>
<table border="0" width="95%">
<tbody>
<tr>
<td>OOP stands for <em>Object-Oriented Programming</em>. It is a programming concept that caught on in the 1990&#8242;s. OOP focuses on &#8216;objects&#8217; which are, well, objects. They have certain characteristics, and can behave in certain ways. OOP programming has a few concepts that define it. One of the defining features we will start with is called a <strong>class</strong>.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>A class shows what an object has and can do, and it consists of <strong>members</strong>. Members can be divided into <strong>properties</strong> and <strong>methods</strong>. Properties are the characteristics of the object. For example, cheese (object) has the properties of type (maybe Gorgonzola, or cheddar), color (green, or white), and flavor (awful or delicious). Methods are the actions and behaviors the object can do. For example, cheese (object) can mold. Now let&#8217;s see the technical side of it.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><strong>PHP</strong></p>
<p>class Cheese { // A class, shows what all cheese has<br />
var $type; // These are a class&#8217;s attributes, or properties<br />
var $flavor; // They are sometimes called characteristics, too.<br />
var $color; // All cheeses have these 3 properties</p>
<p>// These functions are called &#8216;methods&#8217;<br />
// It&#8217;s what the cheese can do for you<br />
// and what you can do for your cheese<br />
function giveDetails ($thetype, $theflavor, $thecolor) {<br />
$this-&gt;type = $thetype;<br />
$this-&gt;flavor = $theflavor;<br />
$this-&gt;color = $thecolor;<br />
}</p>
<p>function showType() {<br />
return $this-&gt;type;<br />
}<br />
function showColor() {<br />
return $this-&gt;color;<br />
}<br />
function showFlavor() {<br />
return $this-&gt;flavor;<br />
}<br />
}</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>You declare a class by using the word &#8216;class&#8217;. It&#8217;s common to define the properties first. You define properties by using &#8216;var&#8217;. Next the methods are defined. When using any of the properties in your methods, you use the $this keyword. If I want to use the &#8220;flavor&#8221; property in a function, I would put $this-&gt;flavor.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Now let&#8217;s see this class in action.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><strong>PHP</strong><br />
class Cheese { // A class, shows what all cheese has<br />
var $type; // These are a class&#8217;s attributes, or properties<br />
var $flavor; // They are sometimes called characteristics, too.<br />
var $color; // All cheeses have these 3 properties</p>
<p>// These functions are called &#8216;methods&#8217;<br />
// It&#8217;s what the cheese can do for you<br />
// and what you can do for your cheese<br />
function giveDetails ($thetype, $theflavor, $thecolor) {<br />
$this-&gt;type = $thetype;<br />
$this-&gt;flavor = $theflavor;<br />
$this-&gt;color = $thecolor;<br />
}</p>
<p>function showType() {<br />
return $this-&gt;type;<br />
}<br />
function showColor() {<br />
return $this-&gt;color;<br />
}<br />
function showFlavor() {<br />
return $this-&gt;flavor;<br />
}<br />
}</p>
<p>$zargento = new Cheese; // Zargento is a brand of cheese</p>
<p>// We will now give it characteristics<br />
$zargento-&gt;giveDetails(&#8220;Gorgonzola&#8221;, &#8220;Awful&#8221;, &#8220;Green and white&#8221;);</p>
<p>// Now let&#8217;s see those details<br />
echo $zargento-&gt;showType();<br />
echo &#8220;<br />
&#8220;; // It seems DIC likes to get rid of my HTML br tags<br />
echo $zargento-&gt;showFlavor();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showColor();</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>You make a new object by using &#8216;new&#8217;. $zargento is now a Cheese object. It has access to all the properties and methods we outlined in the class. If we want $zargento to use the giveDetails() function, you use &#8216;$zargento-&gt;giveDetails()&#8217; as was used above. If you run the above script, the output will be:</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><strong> Gorgonzola</p>
<p>Awful</p>
<p>Green and white </strong></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Now that you&#8217;ve gotten a good idea of how classes work, we can move one step further with another concept of OOP called <strong>inheritance</strong>. This allows you to create new classes using already created classes. Here is an example:</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><strong>PHP</strong><br />
class MoreCheese extends Cheese {<br />
var $cost;</p>
<p>function giveCost($f) {<br />
$this-&gt;cost = $f;<br />
}</p>
<p>function showCost() {<br />
return $this-&gt;cost;<br />
}<br />
}</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>You use &#8216;extends&#8217; to grab the methods and properties from the Cheese class and add them to the MoreCheese class. Let&#8217;s see the full code.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><strong>PHP</strong><br />
class Cheese { // A class, shows what all cheese has<br />
var $type; // These are a class&#8217;s attributes, or properties<br />
var $flavor; // They are sometimes called characteristics, too.<br />
var $color; // All cheeses have these 3 properties</p>
<p>// These functions are called &#8216;methods&#8217;<br />
// It&#8217;s what the cheese can do for you<br />
// and what you can do for your cheese<br />
function giveDetails ($thetype, $theflavor, $thecolor) {<br />
$this-&gt;type = $thetype;<br />
$this-&gt;flavor = $theflavor;<br />
$this-&gt;color = $thecolor;<br />
}</p>
<p>function showType() {<br />
return $this-&gt;type;<br />
}<br />
function showColor() {<br />
return $this-&gt;color;<br />
}<br />
function showFlavor() {<br />
return $this-&gt;flavor;<br />
}<br />
}</p>
<p>class MoreCheese extends Cheese {<br />
var $cost;</p>
<p>function giveCost($f) {<br />
$this-&gt;cost = $f;<br />
}</p>
<p>function showCost() {<br />
return $this-&gt;cost;<br />
}<br />
}</p>
<p>$zargento = new MoreCheese;<br />
$zargento-&gt;giveDetails(&#8220;Gorgonzola&#8221;, &#8220;Awful&#8221;, &#8220;Green and white&#8221;);<br />
$zargento-&gt;giveCost(&#8220;23.39&#8243;);<br />
echo $zargento-&gt;showType();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showFlavor();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showColor();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showCost();</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>As you can see, even though $zargento is no longer Cheese, and is now MoreCheese, it still retains all of the methods and properties from Cheese because the MoreCheese class inherits all of them from Cheese. The advantages to inheritance are that you don&#8217;t have to edit the base class (in this case Cheese). You can also override code, as this example shows.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><strong>PHP</strong><br />
class Cheese { // A class, shows what all cheese has<br />
var $type; // These are a class&#8217;s attributes, or properties<br />
var $flavor; // They are sometimes called characteristics, too.<br />
var $color; // All cheeses have these 3 properties</p>
<p>// These functions are called &#8216;methods&#8217;<br />
// It&#8217;s what the cheese can do for you<br />
// and what you can do for your cheese<br />
function giveDetails ($thetype, $theflavor, $thecolor) {<br />
$this-&gt;type = $thetype;<br />
$this-&gt;flavor = $theflavor;<br />
$this-&gt;color = $thecolor;<br />
}</p>
<p>function showType() {<br />
return $this-&gt;type;<br />
}<br />
function showColor() {<br />
return $this-&gt;color;<br />
}<br />
function showFlavor() {<br />
return $this-&gt;flavor;<br />
}<br />
}</p>
<p>class MoreCheese extends Cheese {<br />
var $cost;</p>
<p>function giveDetails($q) {<br />
echo $q;<br />
}</p>
<p>function giveCost($f) {<br />
$this-&gt;cost = $f;<br />
}</p>
<p>function showCost() {<br />
return $this-&gt;cost;<br />
}<br />
}</p>
<p>$zargento = new MoreCheese;<br />
$zargento-&gt;giveDetails(&#8220;dilly&#8221;);<br />
$zargento-&gt;giveCost(&#8220;23.39&#8243;);<br />
echo $zargento-&gt;showType();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showFlavor();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showColor();<br />
echo &#8220;<br />
&#8220;;<br />
echo $zargento-&gt;showCost();</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>As you can see, the giveDetails() function of the base class Cheese has been overrided by the giveDetails() function of the MoreCheese class. This is a very useful feature of inheritance.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Hope you enjoyed it.</td>
</tr>
</tbody>
</table>
<br />Posted in Simple Oops Concept Tagged: php class, PHP object oriented tutorial, PHP oops <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=30&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/06/29/php-oops-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>301 redirection using htaccess</title>
		<link>http://parmendra.wordpress.com/2009/06/24/301-redirection-using-htaccess/</link>
		<comments>http://parmendra.wordpress.com/2009/06/24/301-redirection-using-htaccess/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 09:16:51 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Permanent redirection through htaccess]]></category>
		<category><![CDATA[301 redirection]]></category>
		<category><![CDATA[Domain Redirection]]></category>
		<category><![CDATA[htaccess redirection]]></category>
		<category><![CDATA[permanentaly redirection]]></category>
		<category><![CDATA[Seo friendly redirection]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=19</guid>
		<description><![CDATA[Redirection using htaccess SEO 301 Redirect Single File Redirect 301 /x/file.html /y/file.html Redirect whole to new Domain Redirect 301 / http://www.yourredirectingdomain.com 301 Redirect multiple files RedirectMatch 301 /articles(.*) /$1 Redirect Entire website to single file This is a 302 (temporary)redirect because its meant to point to a temporarily offline file. RedirectMatch 302 ^/ /temporary-offline.html Redirecting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=19&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Redirection using htaccess</h2>
<p><strong>SEO 301 Redirect Single File</strong></p>
<table style="border:#000000 thin;" border="0" cellspacing="0" cellpadding="0" width="90%" align="center">
<tbody>
<tr>
<td bgcolor="#cccccc"><span class="style1">Redirect 301 /x/file.html /y/file.html</span></td>
</tr>
</tbody>
</table>
<p><strong>Redirect whole to new Domain</strong></p>
<table style="border:#000000 thin;" border="0" cellspacing="0" cellpadding="0" width="90%" align="center">
<tbody>
<tr>
<td bgcolor="#cccccc"><span class="style1">Redirect 301 / http://www.yourredirectingdomain.com</span></td>
</tr>
</tbody>
</table>
<p><strong>301 Redirect multiple files</strong></p>
<table style="border:#000000 thin;" border="0" cellspacing="0" cellpadding="0" width="90%" align="center">
<tbody>
<tr>
<td bgcolor="#cccccc"><span class="style1">RedirectMatch 301 /articles(.*) /$1</span></td>
</tr>
</tbody>
</table>
<p><strong>Redirect Entire website to single file</strong></p>
<table style="border:#000000 thin;" border="0" cellspacing="0" cellpadding="0" width="90%" align="center">
<tbody>
<tr>
<td bgcolor="#cccccc">This is a 302 (<em>temporary</em>)redirect because its meant to point to a temporarily offline file.</p>
<p><span class="style1">RedirectMatch 302 ^/ /temporary-offline.html</span></td>
</tr>
</tbody>
</table>
<p><strong>Redirecting To Trigger Errors</strong></p>
<table style="border:#000000 thin;" border="0" cellspacing="0" cellpadding="0" width="90%" align="center">
<tbody>
<tr>
<td bgcolor="#cccccc"><strong>Redirect 400 /seo/400</strong></p>
<p><strong>Redirect 401 /seo/401</strong></p>
<p><strong>Redirect 402 /seo/402</strong></p>
<p><strong>Redirect 403 /seo/403</strong></p>
<p><strong>Redirect 404  /index.php?error=404</strong></p>
<p><strong>Redirect 405 /seo/405</strong></p>
<p><strong>Redirect 406 /seo/406</strong></p>
<p><strong>Redirect 407 /seo/407</strong></p>
<p><strong>Redirect 408 /seo/408</strong></p>
<p><strong>Redirect 409 /seo/409</strong></p>
<p><strong>Redirect 410 /seo/410</strong></p>
<p><strong>Redirect 411 /seo/411</strong></p>
<p><strong>Redirect 412 /seo/412</strong></p>
<p><strong>Redirect 413 /seo/413</strong></p>
<p><strong>Redirect 414 /seo/414</strong></p>
<p><strong>Redirect 415 /seo/415</strong></p>
<p><strong>Redirect 416 /seo/416</strong></p>
<p><strong>Redirect 417 /seo/417</strong></p>
<p><strong>Redirect 418 /seo/418</strong></p>
<p><strong>Redirect 419 /seo/419</strong></p>
<p><strong>Redirect 420 /seo/420</strong></p>
<p><strong>Redirect 421 /seo/421</strong></p>
<p><strong>Redirect 422 /seo/422</strong></p>
<p><strong>Redirect 423 /seo/423</strong></p>
<p><strong>Redirect 424 /seo/424</strong></p>
<p><strong>Redirect 425 /seo/425</strong></p>
<p><strong>Redirect 426 /seo/426</strong></p>
<p><strong>Redirect 500 /seo/500</strong></p>
<p><strong>Redirect 501 /seo/501</strong></p>
<p><strong>Redirect 502 /seo/502</strong></p>
<p><strong>Redirect 503 /seo/503</strong></p>
<p><strong>Redirect 504 /seo/504</strong></p>
<p><strong>Redirect 505 /seo/505</strong></p>
<p><strong>Redirect 506 /seo/506</strong></p>
<p><strong>Redirect 507 /seo/507</strong></p>
<p><strong>Redirect 508 /seo/508</strong></p>
<p><strong>Redirect 509 /seo/509</strong></p>
<p><strong>Redirect 510 /seo/510</strong></td>
</tr>
</tbody>
</table>
<br />Posted in Permanent redirection through htaccess Tagged: 301 redirection, Domain Redirection, htaccess redirection, permanentaly redirection, Seo friendly redirection <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=19&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/06/24/301-redirection-using-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Swine flu hits West Indies, Indian team keeps fingers crossed</title>
		<link>http://parmendra.wordpress.com/2009/06/24/swine-flu-hits-west-indies-indian-team-keeps-fingers-crossed/</link>
		<comments>http://parmendra.wordpress.com/2009/06/24/swine-flu-hits-west-indies-indian-team-keeps-fingers-crossed/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 04:06:25 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Indian cricket team tour]]></category>
		<category><![CDATA[Indian cricket]]></category>
		<category><![CDATA[Swine flu]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=14</guid>
		<description><![CDATA[Kingston: The Indian cricket team kept its fingers crossed and geared up for the One-day series against the West Indies as the first ever Caribbean Games to be held in Trinidad and Tobago, slated for July, has been cancelled due to the outbreak of swine flu. Trinidad and Tobago&#8217;s Health Minister Jerry Narace and Sports [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=14&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<div><strong>Kingston:</strong> The Indian cricket team kept its fingers crossed and geared up for the One-day series against the West Indies as the first ever Caribbean Games to be held in Trinidad and Tobago, slated for July, has been cancelled due to the outbreak of swine flu.</div>
</div>
<div>Trinidad and Tobago&#8217;s Health Minister Jerry Narace and Sports Minister Gary Hunt said the Games were cancelled to prevent the spread of the influenza A (HINI) virus that has so far spread to more than 76 countries and infected more than 30,000 people.</div>
<div>India, however, will not play any of the four One-dayers in the Port of Spain, the capital of Trinidad and Tobago. They will play two matches each in the neighbouring islands of Jamaica and St. Lucia.</div>
<div>Eighteen confirmed cases of the virus have been found in the twin islands of Trinidad and Tobago and health authorities have warned that the figure is likely to increase in the coming days.</div>
<div>The sports minister said that the cancellation of the Games was &#8220;undoubtedly a major disappointment for many fans who were anxiously anticipating exciting competition.&#8221;</div>
<div>&#8220;No doubt the athletes themselves will feel the greatest disappointment since they have been vigorously preparing to showcase their talents during the games. However, I am confident that they will understand the reasons for this cancellation and they will appreciate the wisdom behind the decision,&#8221; Hunt said.</div>
<div>The outbreak of swine flu also forced the Caribbean Football Union (CFU) to postpone the 2009 Girls&#8217; and Boys&#8217; Youth Cup scheduled to be hosted in Trinidad and Tobago in July and August.</div>
<div>Source: Indo-Asian News Service</div>
<br />Posted in Indian cricket team tour Tagged: Indian cricket, Swine flu <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=14&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/06/24/swine-flu-hits-west-indies-indian-team-keeps-fingers-crossed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Indian team reaches Jamaica</title>
		<link>http://parmendra.wordpress.com/2009/06/22/indian-team-reaches-jamaica/</link>
		<comments>http://parmendra.wordpress.com/2009/06/22/indian-team-reaches-jamaica/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 12:46:58 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Indian cricket team tour]]></category>

		<guid isPermaLink="false">http://parmendra.wordpress.com/?p=10</guid>
		<description><![CDATA[Two days after their World Twenty20 campaign ended, the Indian team has landed in Jamaica for their next assignment, a four-ODI series against West Indies. India have been in great form in one-dayers over the past ten months, losing only three dead matches from 18 games. West Indies performed strongly in the World Twenty20 after [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=10&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Two days after their World Twenty20 campaign ended, the Indian team has landed in Jamaica for their next assignment, a four-ODI series against West Indies.</p>
<p>India have been in great form in one-dayers over the past ten months, losing only three dead matches from 18 games. West Indies performed strongly in the World Twenty20 after a forgettable show against England in the Tests and one-dayers.</p>
<p>&#8220;I think it&#8217;s going to be a competitive cricket (series) and we are looking forward to it,&#8221; MS Dhoni said. &#8221; West Indies is playing good cricket at the moment. They are having a very good World Twenty20 tournament, but in the 50 overs, you have time to settle down.&#8221;</p>
<p>India are missing four first-team players on the tour &#8211; Sachin Tendulkar, Zaheer Khan, Virender Sehwag and Suresh Raina &#8211; but coach Gary Kirsten said this was a chance for the youngsters to shine. &#8220;You&#8217;re always going to miss them because they are great players, but it&#8217;s a great opportunity for a tour of this nature for young players to show what they&#8217;re made of.&#8221;</p>
<p>The first of four one-dayers is on June 26 in Kingston.</p>
<p><strong> ODI</strong><span><strong> : 1<br />
West Indies v India at Kingston </strong></span></p>
<div><span> Jun 26 (09:30 local, 14:30 GMT) </span></div>
<div></div>
<div><strong>ODI</strong><span><strong> : 2<br />
</strong></span></p>
<div><span><strong>West Indies v India at Kingston </strong></span><br />
<span> Jun 28 (09:30 local, 14:30 GMT) </span></div>
</div>
<div></div>
<div>
<div><strong>ODI</strong><span><strong> : 3<br />
</strong></span></p>
<div>
<div><span><strong>West Indies v India at Gros Islet </strong></span><br />
<span> Jul 3 (09:30 local, 13:30 GMT) </span></div>
<p><span></span></div>
<div></div>
<div>
<div><strong>ODI</strong><span><strong> : 4<br />
</strong></span></p>
<div><span><strong>West Indies v India at Gros Islet </strong></span><br />
<span> Jul 5 (09:30 local, 13:30 GMT)</span><span></span></div>
</div>
</div>
</div>
</div>
<br />Posted in Indian cricket team tour  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=10&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2009/06/22/indian-team-reaches-jamaica/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>
	</item>
		<item>
		<title>Pakistan crush Lanka to win T20 World Cup</title>
		<link>http://parmendra.wordpress.com/2008/09/06/pakistan-crush-lanka-to-win-t20-world-cup/</link>
		<comments>http://parmendra.wordpress.com/2008/09/06/pakistan-crush-lanka-to-win-t20-world-cup/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 06:13:20 +0000</pubDate>
		<dc:creator>parmendra</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[LONDON: Pakistan won their first major title in 17 years when they stunned Sri Lanka by eight wickets in the World Twenty20 final at a sell-out More Pictures Lord&#8217;s on Sunday. Seamer Abdur Razzaq claimed three wickets as Pakistan bowled and fielded aggressively to restrict Sri Lanka to 138-6, then coasted home easily with eight [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=1&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>LONDON: <span style="text-decoration:underline!important;position:static;"><span style="color:blue!important;font-weight:400;font-size:12px;position:static;"><span style="color:blue!important;font-family:Arial,Helvetica,sans-serif;font-weight:400;font-size:12px;position:static;">Pakistan</span></span></span> won their first major title in 17 years when they stunned Sri Lanka by eight wickets in the World Twenty20 final at a sell-out</p>
<table style="margin-top:3px;margin-right:6px;" border="0" cellspacing="0" cellpadding="0" width="205" align="left">
<tbody>
<tr>
<td style="padding-left:3px;">
<div>
<div><a href="openslideshow('/slideshow/4684945.cms')"><img title="Pakistan" src="http://cricket.timesofindia.indiatimes.com/thumb.cms?msid=4684945&amp;width=200&amp;resizemode=4" border="0" alt="Pakistan" vspace="0" /></a></p>
<div><a href="openslideshow('/slideshow/4684945.cms')"><img src="http://cricket.timesofindia.indiatimes.com/photo.cms?msid=3000949" border="0" alt="" /></a></div>
</div>
<div><a href="openslideshow('/slideshow/4684945.cms')">More Pictures</a></div>
</div>
</td>
</tr>
</tbody>
</table>
<p>Lord&#8217;s on Sunday.<br />
Seamer Abdur Razzaq claimed three wickets as Pakistan bowled and fielded aggressively to restrict Sri Lanka to 138-6, then coasted home easily with eight deliveries to spare.</p>
<p>Blogs:  <a href="http://blogs.timesofindia.indiatimes.com/justso/entry/fighting-gunpower-with-the-willow"> Fighting gunpower with willow </a> |  <a href="http://blogs.timesofindia.indiatimes.com/Between-the-Lies/entry/this-cup-has-been-a"> This Cup has been a game-changer </a></p>
<p>Shahid Afridi hit an unbeaten 54 off 40 balls, his second consecutive half-century, and former captain Shoaib Malik made 24 not out during a match-winning partnership of 76 for the undefeated third wicket.</p>
<p>Pakistan, runners-up to India in the final of the inaugural World Twenty20 in South Africa two years ago, ended Sri Lanka&#8217;s unbeaten run in the tournament with style.</p>
<p>Pakistan last won an offical multi-nation tournament in 1992 when Imran Khan&#8217;s team lifted the World Cup by beating <a id="KonaLink1" style="text-decoration:underline!important;position:static;" href="http://cricket.timesofindia.indiatimes.com/articleshow/4684822.cms#" target="undefined"><span style="color:blue!important;font-weight:400;font-size:12px;position:static;"><span style="color:blue!important;font-family:Arial,Helvetica,sans-serif;font-weight:400;font-size:12px;position:static;">England</span></span></a> in the final at the Melbourne cricket ground in Australia.</p>
<p>Sunday&#8217;s win by Younus Khan&#8217;s team gave Pakistanis back home reason to cheer as the cricket-mad nation has been deprived of international <a id="KonaLink2" style="text-decoration:underline!important;position:static;" href="http://cricket.timesofindia.indiatimes.com/articleshow/4684822.cms#" target="undefined"><span style="color:blue!important;font-weight:400;font-size:12px;position:static;"><span style="color:blue!important;font-family:Arial,Helvetica,sans-serif;font-weight:400;font-size:12px;position:static;">tours</span></span></a> due to security concerns in the volatile nation.</p>
<p>The International <a id="KonaLink3" style="text-decoration:underline!important;position:static;" href="http://cricket.timesofindia.indiatimes.com/articleshow/4684822.cms#" target="undefined"><span style="color:blue!important;font-weight:400;font-size:12px;position:static;"><span style="color:blue!important;font-family:Arial,Helvetica,sans-serif;font-weight:400;font-size:12px;position:static;">Cricket</span></span></a> Council has already ruled out holding World Cup matches in Pakistan in 2011 following the militant attack on the Sri Lankan team in Lahore on March 3.</p>
<p>Pakistani openers Kamran Akmal and Shahzaib Hasan ensured there were no early scares as they put on 48 for the first wicket in seven overs.</p>
<p>Sanath Jayasuriya broke through with his first delivery in the next over when he beat Akmal in the air with his left-arm spin and had him stumped for 37 off 28 balls.</p>
<p>Jayasuriya then took a catch to get rid of Shahzaib off Muttiah Muralitharan for 19, but Afridi and Malik took Pakistan home amid loud celebrations from their fans in the stands.</p>
<p>Sri Lanka were dealt quick blows after captain Kumar Sangakkara won the toss and elected to take first strike on a slow wicket.</p>
<p>The Lankans slumped to 2-2 in the first nine balls and that became 34-4 before Sangakkara himself led the rescue act with a defiant unbeaten 64 from 52 balls.</p>
<p>Sangakkara and Angelo Mathews put on 68 for the unbroken seventh wicket as Sri Lanka plundered 59 runs in the final five overs.</p>
<p>Mathews returned unbeaten on 35 off 24 balls.</p>
<p>Pakistan got off to a sensational start when teenage fast bowler Mohammad Aamir sent back the in-form Tillekaratne Dilshan with the fifth ball of the match.</p>
<p>Dilshan, the <a id="KonaLink4" style="text-decoration:underline!important;position:static;" href="http://cricket.timesofindia.indiatimes.com/articleshow/4684822.cms#" target="undefined"><span style="color:blue!important;font-weight:400;font-size:12px;position:static;"><span style="color:blue!important;font-family:Arial,Helvetica,sans-serif;font-weight:400;font-size:12px;position:static;">tournament&#8217;s</span></span></a> leading scorer with 317 runs, miscued a pull shot off the speedy left-armer and was caught at backward square-leg by Shahzaib Hasan for zero.</p>
<p>Four balls later, Shahzaib grabbed his second catch at mid-off as Jehan Mubarak skied a leading edge off Razzaq, who shared the new ball with Aamir.</p>
<p>Jayasuriya counter-attacked with a six and four in Razzaq&#8217;s second over, but the bowler hit back two balls later as the left-handed veteran edged a ball on to his stumps after making 17.</p>
<p>Razzaq, who replaced the injured Yasir Arafat after ending his links with the rebel Indian <a id="KonaLink5" style="text-decoration:underline!important;position:static;" href="http://cricket.timesofindia.indiatimes.com/articleshow/4684822.cms#" target="undefined"><span style="color:blue!important;font-weight:400;font-size:12px;position:static;"><span style="color:blue!important;font-family:Arial,Helvetica,sans-serif;font-weight:400;font-size:12px;position:static;">Cricket</span></span></a> League, struck again in his third over when Misbah-ul Haq dived to his right at slip to remove Mahela Jayawardene for one.</p>
<p>(content from http://cricket.timesofindia.indiatimes.com)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/parmendra.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/parmendra.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/parmendra.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/parmendra.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/parmendra.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/parmendra.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/parmendra.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/parmendra.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/parmendra.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/parmendra.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=parmendra.wordpress.com&amp;blog=4748317&amp;post=1&amp;subd=parmendra&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://parmendra.wordpress.com/2008/09/06/pakistan-crush-lanka-to-win-t20-world-cup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/95ec0342c2128df0307adcd6a818fa8c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">parmendra</media:title>
		</media:content>

		<media:content url="http://cricket.timesofindia.indiatimes.com/thumb.cms?msid=4684945&#38;width=200&#38;resizemode=4" medium="image">
			<media:title type="html">Pakistan</media:title>
		</media:content>

		<media:content url="http://cricket.timesofindia.indiatimes.com/photo.cms?msid=3000949" medium="image" />
	</item>
	</channel>
</rss>
