<?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/"
	>

<channel>
	<title>Learning Is Fun &#187; Blog</title>
	<atom:link href="http://www.tanzilo.com/category/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tanzilo.com</link>
	<description>Talks on Web Technology and Better Product Development</description>
	<lastBuildDate>Sat, 17 Jan 2009 22:17:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>WordPress: How to add and link static or custom pages</title>
		<link>http://www.tanzilo.com/2008/11/02/wordpress-how-to-add-and-link-static-or-custom-pages/</link>
		<comments>http://www.tanzilo.com/2008/11/02/wordpress-how-to-add-and-link-static-or-custom-pages/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 20:53:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[custom page]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[permalink]]></category>
		<category><![CDATA[protect]]></category>
		<category><![CDATA[static page]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=23</guid>
		<description><![CDATA[When I was new to wordpress theme development, I faced a common problem that many others might have faced. That is adding or linking or integrating a static or custom page in your wordpress site. It is very possible that you may prefer to keep one of your page or file linked as the following: [...]]]></description>
			<content:encoded><![CDATA[<p>When I was new to wordpress theme development, I faced a common problem that many others might have faced. That is adding or linking or integrating a static or custom page in your wordpress site. It is very possible that you may prefer to keep one of your page or file linked as the following:</p>
<p>http://www.yoursitename.com/products.php</p>
<p>Sometimes this kind of requirement arrive that you have no other option but to do it.</p>
<p>But you know this kind of link will not directly appear in your wordpress blog or site because of the unique linking structure of wordpress. Most probably you will get a 404 error i.e. file not found error. So, if you want to link directly, you need to follow a simple trick. This trick is simple, small and intereting.</p>
<p>If you want to add and link your custom or static pages, follow these steps and you will get smooth result:</p>
<p><span style="text-decoration: underline;"><strong>Step One: Changing the header of the php file</strong></span></p>
<p>In this article, we will add a <strong>php</strong> file <span style="text-decoration: underline;">products.php</span> in our wordpress blog. So, please create your products.php file.  Now open you <span style="text-decoration: underline;">products.php</span> file and add the following two lines at the top of the file and save your file.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
	<span class="phpFunction">define</span><span class="phpOperator">(</span><span class="phpString">'WP_USE_THEMES'</span>,<span class="phpKeyword"> false<span class="phpOperator">)</span></span><span class="phpText">;</span>
<span class="phpKeyword">	require<span class="phpOperator">(</span></span><span class="phpString">'<span class="phpOperator">.</span>/wp-blog-header.php'</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Remember, these lines will be the topmost lines in your <span style="text-decoration: underline;">products.php</span> file. OK? See below how I added.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
	<span class="phpFunction">define</span><span class="phpOperator">(</span><span class="phpString">'WP_USE_THEMES'</span>,<span class="phpKeyword"> false<span class="phpOperator">)</span></span><span class="phpText">;</span>
<span class="phpKeyword">	require<span class="phpOperator">(</span></span><span class="phpString">'<span class="phpOperator">.</span>/wp-blog-header.php'</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span class="htmlOtherTag">&lt;html xmlns=<span class="htmlAttributeValue">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span class="htmlOtherTag">&lt;head&gt;</span>
<span class="htmlOtherTag">&lt;meta http-equiv=<span class="htmlAttributeValue">&quot;Content-Type&quot;</span> content=<span class="htmlAttributeValue">&quot;text/html; charset=utf-8&quot;</span> /&gt;</span>
<span class="htmlOtherTag">&lt;title&gt;</span>Our Products<span class="htmlOtherTag">&lt;/title&gt;</span>
<span class="htmlOtherTag">&lt;/head&gt;</span>
<span class="htmlComment"><span class="htmlOtherTag">&lt;!-- Other lines of coding --&gt;</span></span>
</pre>
<p>Why are we adding these two lines? Because we are telling wordpress that this file will not use wordpress themes and we are going to link it in a different way. So, wordpress do not force to link in its usual way.</p>
<p><span style="text-decoration: underline;"><strong>Step Two: Saving in the public_html or root folder</strong></span></p>
<p>Now upload it in the wordpress installation directory so that it looks like:</p>
<p>http://www.yoursitename.com/products.php</p>
<p>Done? Great!</p>
<p><span style="text-decoration: underline;"><strong>Step Three: Linking the products.php file in a usual way</strong></span></p>
<p>Now in the code of any wordpress file where you want to link your <span style="text-decoration: underline;">products.php</span> file, keep the html linking as usual or what we say relative linking. For example, in the contact us page, I am creating such a link in the body section:</p>
<pre class="html">
<span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;http://www.tanzilo.com/wp-admin/products.php&quot;</span>&gt;</span>Our Products<span class="htmlAnchorTag">&lt;/a&gt;</span>
</pre>
<p>And yes! We are done!<br />
Test now if it works for you.</p>
<p>Thus, you can add any number of pages in your wordperss site. I do not know exactly when you may need to link this way. I had to do it time to time depending on the client&#8217;s project requirement.</p>
<p>Thus, you can also protect your pages from permalink (dot)htaccess in wordpress.</p>
<p>Thanks for reading.</p>
<p><map name='google_ad_map_23_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/23?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_23_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=23&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F11%2F02%2Fwordpress-how-to-add-and-link-static-or-custom-pages%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/11/02/wordpress-how-to-add-and-link-static-or-custom-pages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress: get page content by page id. Static pages to Dynamic</title>
		<link>http://www.tanzilo.com/2008/11/01/wordpress-get-page-content-by-page-id-static-pages-to-dynamic/</link>
		<comments>http://www.tanzilo.com/2008/11/01/wordpress-get-page-content-by-page-id-static-pages-to-dynamic/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 09:08:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[page content]]></category>
		<category><![CDATA[page id]]></category>
		<category><![CDATA[post content]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=22</guid>
		<description><![CDATA[Hello! Recently I am working in a wordpress project where I am converting a total static site to wordpress site. What I do is: (1) from the static pages, I am taking the static text and creating a new wordpress page for each static page. (2) fetching the page content/text by page id and (3) [...]]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>Recently I am working in a wordpress project where I am converting a total static site to wordpress site. What I do is: (1) from the static pages, I am taking the static text and creating a new wordpress page for each static page. (2) fetching the page content/text by page id and (3) showing them wherever I want.</p>
<p>I have written a function and now I can fetch the content of any page or one more pages just by the page id.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction"><span class="phpFunctionKeyword">function</span>_exists</span><span class="phpOperator">(</span><span class="phpString">'getPageContent'</span><span class="phpOperator">)</span><span class="phpOperator">)</span>
	<span class="phpOperator">{</span>
		<span class="phpFunctionKeyword">function</span><span class="htmlText"> getPageContent</span><span class="phpOperator">(</span>$pageId<span class="phpOperator">)</span>
		<span class="phpOperator">{</span>
		<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction">is_numeric</span><span class="phpOperator">(</span>$pageId<span class="phpOperator">)</span><span class="phpOperator">)</span>
			<span class="phpOperator">{</span>
			<span class="phpKeyword">	return<span class="phpText">;</span></span>
			<span class="phpOperator">}</span>
		<span class="phpKeyword">	global </span>$wpdb<span class="phpText">;</span>
			$sql_query <span class="phpOperator">=</span> <span class="phpString">'SELECT DISTINCT * FROM '</span> <span class="phpOperator">.</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">posts </span><span class="phpOperator">.</span>
			<span class="phpString">' WHERE '</span> <span class="phpOperator">.</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">posts </span><span class="phpOperator">.</span> <span class="phpString">'<span class="phpOperator">.</span><span class="htmlText">ID</span><span class="phpOperator">=</span>'</span> <span class="phpOperator">.</span> $pageId<span class="phpText">;</span>
			$posts <span class="phpOperator">=</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">get_results</span><span class="phpOperator">(</span>$sql_query<span class="phpOperator">)</span><span class="phpText">;</span>
		<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction">empty</span><span class="phpOperator">(</span>$posts<span class="phpOperator">)</span><span class="phpOperator">)</span>
			<span class="phpOperator">{</span>
			<span class="phpKeyword">	foreach<span class="phpOperator">(</span></span>$posts<span class="phpKeyword"> as </span>$post<span class="phpOperator">)</span>
				<span class="phpOperator">{</span>
				<span class="phpKeyword">	return </span><span class="phpFunction">nl2br</span><span class="phpOperator">(</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">post_content</span><span class="phpOperator">)</span><span class="phpText">;</span>
				<span class="phpOperator">}</span>
			<span class="phpOperator">}</span>
		<span class="phpOperator">}</span>
	<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>I am using this function to fetch several page data and show them in one page. In the static site, there are several section with different designs. The client want edit each section using wordpress. So, if there are three different sections, I am creating three individual pages for this single page. Next, I am just fetching the content of the three pages by calling my method three times with different parameters and showing the output in one page.</p>
<p>For exampe,</p>
<pre class="php">
<span class="htmlOtherTag">&lt;div id=<span class="htmlAttributeValue">&quot;income_tax&quot;</span>&gt;</span>
	<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span><span class="htmlText"> getPageContent</span><span class="phpOperator">(</span><span class="phpNumber">6</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div id=<span class="htmlAttributeValue">&quot;tax_advise&quot;</span>&gt;</span>
	<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span><span class="htmlText"> getPageContent</span><span class="phpOperator">(</span><span class="phpNumber">7</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
<span class="htmlOtherTag">&lt;div id=<span class="htmlAttributeValue">&quot;yearly_return&quot;</span>&gt;</span>
	<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span> <span class="phpFunction">echo</span><span class="htmlText"> getPageContent</span><span class="phpOperator">(</span><span class="phpNumber">8</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>Thus, I am just shifting all text and/or content of the static site to wordpress so that the client can edit the site himself. I think this is a simple way or technique if you want to convert your static page to dynamic wordpress site.</p>
<p>You can also customize this one as per your need. For example, you may only need to fetch the page title.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction"><span class="phpFunctionKeyword">function</span>_exists</span><span class="phpOperator">(</span><span class="phpString">'getPageTitle'</span><span class="phpOperator">)</span><span class="phpOperator">)</span>
	<span class="phpOperator">{</span>
		<span class="phpFunctionKeyword">function</span><span class="htmlText"> getPageTitle</span><span class="phpOperator">(</span>$pageId<span class="phpOperator">)</span>
		<span class="phpOperator">{</span>
		<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction">is_numeric</span><span class="phpOperator">(</span>$pageId<span class="phpOperator">)</span><span class="phpOperator">)</span>
			<span class="phpOperator">{</span>
			<span class="phpKeyword">	return<span class="phpText">;</span></span>
			<span class="phpOperator">}</span>
		<span class="phpKeyword">	global </span>$wpdb<span class="phpText">;</span>
			$sql_query <span class="phpOperator">=</span> <span class="phpString">'SELECT DISTINCT * FROM '</span> <span class="phpOperator">.</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">posts </span><span class="phpOperator">.</span>
			<span class="phpString">' WHERE '</span> <span class="phpOperator">.</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">posts </span><span class="phpOperator">.</span> <span class="phpString">'<span class="phpOperator">.</span><span class="htmlText">ID</span><span class="phpOperator">=</span>'</span> <span class="phpOperator">.</span> $pageId<span class="phpText">;</span>
			$posts <span class="phpOperator">=</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">get_results</span><span class="phpOperator">(</span>$sql_query<span class="phpOperator">)</span><span class="phpText">;</span>
		<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction">empty</span><span class="phpOperator">(</span>$posts<span class="phpOperator">)</span><span class="phpOperator">)</span>
			<span class="phpOperator">{</span>
			<span class="phpKeyword">	foreach<span class="phpOperator">(</span></span>$posts<span class="phpKeyword"> as </span>$post<span class="phpOperator">)</span>
				<span class="phpOperator">{</span>
				<span class="phpKeyword">	return </span><span class="phpFunction">nl2br</span><span class="phpOperator">(</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">post_title</span><span class="phpOperator">)</span><span class="phpText">;</span>
				<span class="phpOperator">}</span>
			<span class="phpOperator">}</span>
		<span class="phpOperator">}</span>
	<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>You can not only get the page content, but also the post content if you set the value of the &#8220;$pageId&#8221; equals any post id. You know you can see the page or post id from the admin panel.</p>
<p>By the way,<br />
I have put my functions in the functions.php file so that I can access it from anywhere. I suggest you following the same way i.e. writing all your custom functions in the functions.php file.</p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_22_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/22?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_22_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=22&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F11%2F01%2Fwordpress-get-page-content-by-page-id-static-pages-to-dynamic%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/11/01/wordpress-get-page-content-by-page-id-static-pages-to-dynamic/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Password protect sub-directory in wordpress by htaccess</title>
		<link>http://www.tanzilo.com/2008/10/18/password-protect-sub-directory-in-wordpress-by-htaccess/</link>
		<comments>http://www.tanzilo.com/2008/10/18/password-protect-sub-directory-in-wordpress-by-htaccess/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 07:35:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Password]]></category>
		<category><![CDATA[protect]]></category>
		<category><![CDATA[sub-directory]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=18</guid>
		<description><![CDATA[Hello! Recently a Canadian client of mine told me to look at an interesting wordpress problem. I regularly develop wordpress theme for him. He is a great artisitic designer of wordpress theme and I code theme to HTML &#38; CSS. Whatever, my client told me that he wants to password protect a sub-directory &#8220;download&#8221;. He [...]]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>Recently a Canadian client of mine told me to look at an interesting wordpress problem. I regularly develop wordpress theme for him. He is a great artisitic designer of wordpress theme and I code theme to HTML &amp; CSS. Whatever, my client told me that he wants to password protect a sub-directory &#8220;download&#8221;. He has done it from cPanel. He also created a user and permitted that user in that sub-directory. But it was not working.</p>
<p>Befoer I start, I want to clear that in this case wordpress was installed in root directory. One more thing is in this post i cannot write &#8220;.&#8221; and &#8220;htaccess&#8221; together. May be this is a security issue. If I write &#8220;.&#8221; and &#8220;htaccess&#8221; together, the post is not saved and I get a 404 error. So, I have written <span style="text-decoration: underline;">(dot)htaccess</span> instead. Again, <span style="text-decoration: underline;">(dot)htpasswds</span> instead of &#8220;.&#8221; and &#8220;htpasswds&#8221; together.</p>
<p>So I logged in to the cPanel to check what is happening actually. I found that whenever you password protect a sub-directory from cPanel, a new <span style="text-decoration: underline;">(dot)htaccess</span> file will be created in that sub-directory. And the content of the <span style="text-decoration: underline;">(dot)htaccess</span> file is less or more like as follows:</p>
<p><span style="color: #800000;">AuthType Basic AuthName &#8220;Authorized Area!&#8221;<br />
AuthUserFile &#8220;/home/ftpusername/(dot)htpasswds/public_html/download/passwd&#8221;<br />
require valid-user<br />
</span><br />
And your password that you set from the cPanel will be encrypted and saved in a file <span style="text-decoration: underline;">(dot)htpasswds</span> in the <span style="color: #800000;">AuthUserFile</span> location.</p>
<p>If this was not a wordpress site or it was a wordpress site (but custom Permalink not used; rather the Default used), you should not face problem in most cases. But when you use customized Permalink in wordpress to create beautiful links and try to protect a password, the password protection from cPanel does not work!</p>
<p>But do you know why? Here is the reason: in the root directory you installed wordpress and here there is a <span style="text-decoration: underline;">(dot)htaccess</span> file. The settings in this file and the <span style="text-decoration: underline;">(dot)htaccess</span> in your sub-directory (for example root_directory/download/(dot)htaccess) do not smoothly match with each other with since you are using Permalink plug-in to customize your URLs.</p>
<p>So, when you try to go to: http://www.yoursitename.com/download wordpress think that it is a post or page!</p>
<p>WordPress think this because you have enables permalink and this is quite correct and logical. But you know your download sub-directory is not a post but a folder/directory in the root folder. So, you need to do something so that wordpress does not confuse the following link as a post or page.</p>
<p>http://www.yoursitename.com/download</p>
<p>Here is the solution:<br />
1. Open the <span style="text-decoration: underline;">(dot)htaccess</span> file in http://www.yoursitename.com/(dot)htaccess<br />
2. Find out the line # BEGIN WordPress<br />
3. Just before this, add the following three lines:<br />
<span style="color: #800000;"> # To bypass download directory<br />
</span> <span style="color: #800000;">ErrorDocument 401 /%{REQUEST_URI}/myerror.html<br />
ErrorDocument 403 /%{REQUEST_URI}/myerror.html<br />
</span><span style="color: #800000;"> </span>4. Save the <span style="text-decoration: underline;">(dot)htaccess</span> file and upload in your root or installation directory.</p>
<p>Now go to http://www.yoursitename.com/download and check if it works. If everything is OK, you should get a prompt asking for a username and password that you set from the cPanel.</p>
<p>Here is my example:<br />
Sub-directory download password protected: <a title="Download Link" href="http://www.tanzilo.com/download" target="_blank">http://www.tanzilo.com/download</a><br />
Permalink smoothly working: <a title="Password protect sub-directory in wordpress by htaccess" href="http://www.tanzilo.com/2008/10/18/password-protect-sub-directory-in-wordpress-by-htaccess/" target="_blank">http://www.tanzilo.com/2008/10/18/password-protect-sub-directory-in-wordpress-by-htaccess/</a></p>
<p>Or you may install a shopping cart in location as in:</p>
<p>http://www.yoursitename.com/shop</p>
<p>This should work smoothly too as you see my example here:<br />
<a href="http://tanzilo.com/shop" target="_blank">http://tanzilo.com/shop</a></p>
<p>Although there is an application/software in the shop sub-directory, wordpress no more thinks it a post or page!</p>
<p>Thus, you can set <span style="text-decoration: underline;">(dot)htaccess</span>, password protected sub-directory (i.e. /download/) and any other sub-directory (i.e. /shop/) in such a way that they will be living in happiness in the same home!</p>
<p>The last interesting thing is this solution is sometimes helpful in Drupal and in some other applications where <span style="text-decoration: underline;">(dot)htaccess</span> and URL rewriting code do not fit together.</p>
<p>Thanks for reading.</p>
<p><map name='google_ad_map_18_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/18?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_18_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=18&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F10%2F18%2Fpassword-protect-sub-directory-in-wordpress-by-htaccess%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/10/18/password-protect-sub-directory-in-wordpress-by-htaccess/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
