<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>
<channel>
	<title>Blog.ChenHow.Net &#187; htaccess</title>
	<atom:link href="http://blog.chenhow.net/tag/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chenhow.net</link>
	<description>Tech news, reviews, linux tips &#38; tricks, gadgets, foods and life experience sharing</description>
	<lastBuildDate>Wed, 21 Dec 2011 03:32:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<copyright>Copyright &#xA9; Blog.ChenHow.Net 2010 </copyright>
	<managingEditor>chenhow@chenhow.net (Blog.ChenHow.Net)</managingEditor>
	<webMaster>chenhow@chenhow.net (Blog.ChenHow.Net)</webMaster>
	<image>
		<url>http://blog.chenhow.net/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>Blog.ChenHow.Net</title>
		<link>http://blog.chenhow.net</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>Tech news, reviews, linux tips &#38; tricks, gadgets, foods and life experience sharing</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Society &#38; Culture" />
	<itunes:author>Blog.ChenHow.Net</itunes:author>
	<itunes:owner>
		<itunes:name>Blog.ChenHow.Net</itunes:name>
		<itunes:email>chenhow@chenhow.net</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://blog.chenhow.net/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>&quot;.htaccess&quot; tips and tricks</title>
		<link>http://blog.chenhow.net/2009/06/30/internet/htaccess-tips-and-tricks/</link>
		<comments>http://blog.chenhow.net/2009/06/30/internet/htaccess-tips-and-tricks/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:32:03 +0000</pubDate>
		<dc:creator>chenhow</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[htaccess]]></category>
		<guid isPermaLink="false">http://blog.chenhow.net/?p=8</guid>
		<description><![CDATA[By using .htaccess files, we can control access to our web content by allowing/blocking certain user or ip addresses to access. You may ask why do we need that, if you can do the same by using options like &#8220;order, limit&#8221; to restrict ip addresses and user actions in httpd.conf. Fair enough, but there is [...]]]></description>
			<content:encoded><![CDATA[<p>By using .htaccess files, we can control access to our web content by allowing/blocking certain user or ip addresses to access.</p>
<p>You may ask why do we need that, if you can do the same by using options like &#8220;order, limit&#8221; to restrict ip addresses and user actions in httpd.conf.</p>
<p>Fair enough, but there is some limitations.</p>
<p>Given below example:</p>
<p>1) Let say you are a system administrator in ABC company and your company have a few branches over the world. All these branches located in Malaysia, Singapore, Taiwan and China. And each branches will have their own web directories to store all the documents.</p>
<p>Each branches office have a static ip and domain name</p>
<p>Malaysia    1.2.3.4        www.abc.my</p>
<p>Singapore    2.3.4.5        www.abc.sg</p>
<p>Taiwan        3.4.5.6        www.abc.tw</p>
<p>China        4.5.6.7        www.abc.cn</p>
<p>Scenario 1:</p>
<p>You boss came to you and ask whether you could restrict all the web directories, that only allow all the branches access, public user shouldn&#8217;t be able to view or access to it.  Well, it&#8217;s easy , you just need to change the httpd.conf</p>
<p>httpd.conf</p>
<blockquote><p><span style="color: #ffffff;">AllowOverride None Options AuthConfig <span style="color: #ff0000;"># Allow use of the authorization directives</span></span></p>
<p>Order deny,allow</p>
<p>deny from all</p>
<p>allow 1.2.3.4</p>
<p>allow 2.3.4.5</p>
<p>allow 3.4.5.6</p>
<p>allow 4.5.6.7</p></blockquote>
<p>Scenario 2:</p>
<p>But, in the same time , he wants to access all these directories from his house, which using dial up connection and doesn&#8217;t have a static ip address.</p>
<p>Either you advice him to apply a fix line or ask him to register dynamic dns, definitely your boss will not like it.</p>
<p>So the best solution is to control the web content with valid &#8216;username&#8217; and &#8216;passwd&#8217;,</p>
<p>Simply create a .htaccess in protect folder and add the following lines</p>
<blockquote><p><span style="color: #ffffff;">Options  Indexes</span> <span style="color: #ff0000;">#to enable directory listing</span></p>
<p><span style="color: #ffffff;">AuthName     &#8220;Password Protected by .htacce<span style="color: #ffffff;">ss</span></span><span style="color: #ffffff;">&#8220;</span> <span style="color: #ff0000;">#Message that prompt when asking for username and password</span></p>
<p><span style="color: #ffffff;">Authtype     Basic </span></p>
<p>AuthUserFile /usr/local/apache2/passwd <span style="color: #ff0000;">#password file location</span></p>
<p><span style="color: #ffffff;">require user boss</span> <span style="color: #ff0000;">#username boss</span></p>
<p><span style="color: #ffffff;">satisfy any</span> <span style="color: #ff0000;">#either u r using malaysia,china,singapore n taiwan ip or u have a valid username and password, then u can view and access this directory</span></p></blockquote>
<p>if &#8216;satisfy all&#8217;, mean you must have one of the country ip and have to provide valid username and password in order to access.</p>
<p>Generate username and password file</p>
<blockquote><p><span style="color: #ffffff;">htpasswd -c /usr/local/apache2/passwd boss</span></p>
<p><span style="color: #ff0000;">-c is to create new passwd file, if u want to use back the existing password file</span></p>
<p><span style="color: #ffffff;">htpasswd /usr/local/apache2/passwd boss2</span></p></blockquote>
<p>Done. It would be easier and provide more flexibility rather than changing the httpd.conf file and restart the webserver to apply the change.</p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li>No Related Posts</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.chenhow.net/2009/06/30/internet/htaccess-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

