<?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:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>DigiMantra &#187; Apache</title>
	<atom:link href="http://www.digimantra.com/category/technology/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digimantra.com</link>
	<description>Technology tips for all</description>
	<lastBuildDate>Fri, 16 Jul 2010 06:28:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<atom:link rel='hub' href='http://www.digimantra.com/?pushpress=hub'/>
		<item>
		<title>How to restart Apache server from shell</title>
		<link>http://www.digimantra.com/technology/apache/restart-apache-server-shell/</link>
		<comments>http://www.digimantra.com/technology/apache/restart-apache-server-shell/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 09:30:53 +0000</pubDate>
		<dc:creator>Sachin Khosla</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.digimantra.com/?p=2562</guid>
		<description><![CDATA[Know how to restart Apache server from the shell.


Related posts:<ol><li><a href='http://www.digimantra.com/linux/how-to-make-shell-or-sh-bin-file-executable-in-ubuntu/' rel='bookmark' title='Permanent Link: How to make shell or sh , bin file executable in ubuntu'>How to make shell or sh , bin file executable in ubuntu</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/mysql/transfer-database-host-mysqldump-shell/' rel='bookmark' title='Permanent Link: Transfer database from one host to other using mysqldump  and shell'>Transfer database from one host to other using mysqldump  and shell</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey Folks, </p>
<p>&#160;</p>
<p>You need to restart your Apache server when you change settings in php.in, httpd.conf&#160; or some other config file. You need to restart the server because the changes which you made will only effect after the restart. </p>
<p>To restart your server, simply type the following command in your shell. </p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">;type the following command in your shell
/etc/init.d/httpd restart</pre></div></div>

<p>Hope that helps. </p>
<p>Stay Digified !!   <br />Sachin Khosla</p>


<p>Related posts:<ol><li><a href='http://www.digimantra.com/linux/how-to-make-shell-or-sh-bin-file-executable-in-ubuntu/' rel='bookmark' title='Permanent Link: How to make shell or sh , bin file executable in ubuntu'>How to make shell or sh , bin file executable in ubuntu</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/mysql/transfer-database-host-mysqldump-shell/' rel='bookmark' title='Permanent Link: Transfer database from one host to other using mysqldump  and shell'>Transfer database from one host to other using mysqldump  and shell</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.digimantra.com/technology/apache/restart-apache-server-shell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Change default php.ini values using .htaccess</title>
		<link>http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/</link>
		<comments>http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 17:48:49 +0000</pubDate>
		<dc:creator>Sachin Khosla</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.digimantra.com/?p=2357</guid>
		<description><![CDATA[Hey Folks, &#160; As you might be knowing that php.ini is the configuration file for the PHP and resides at the server. It contains all the options/settings for the PHP language. There are instances you need to change these options. In local environment you can change these settings very easily but when on remote server [...]


Related posts:<ol><li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
<li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work'>Using .htaccess for day to day work</a></li>
<li><a href='http://www.digimantra.com/google/google-chrome-change-default-download-location/' rel='bookmark' title='Permanent Link: Google Chrome : Change default download location'>Google Chrome : Change default download location</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey Folks, </p>
<p>&#160;</p>
<p>As you might be knowing that <strong>php.ini </strong>is the configuration file for the PHP and resides at the server. It contains all the options/settings for the PHP language. There are instances you need to change these options. In local environment you can change these settings very easily but when on remote server you do not have permission to edit/change this file. </p>
<p>Before you can overwrite the php.ini values, you need to have the following two lines present at the top of your .htaccess file to make the changes work. </p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">AllowOverride</span> <span style="color: #00007f;">Options</span>
<span style="color: #00007f;">AllowOverride</span> <span style="color: #00007f;">All</span></pre></div></div>

<p>Following is the way to set values in php.ini using .htaccess. For example if you want to enable PHP error log and turn on the error display using .htaccess you will need to write the following in your .htaccess file. </p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">php_flag display_errors <span style="color: #0000ff;">On</span>
php_flag log_errors <span style="color: #0000ff;">On</span></pre></div></div>

<p>There are two kind of directives which can be set in .htaccess. <strong>php_value </strong>for the string type of values and <strong>php_flag </strong>for the boolean values. In the above example we used later to set the errors on which is a boolean value. An example to set <strong>php_value</strong>&#160; would be to change the default memory limit and default post size. </p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">php_value</span> post_max_size 8M
<span style="color: #00007f;">php_value</span> memory_limit 32M</pre></div></div>

<p>You can change the values of various options listed in <strong>php.ini </strong>via .htaccess. Hope this helps.</p>
<p>Stay Digified !!<br />
  <br />Sachin Khosla</p>


<p>Related posts:<ol><li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
<li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work'>Using .htaccess for day to day work</a></li>
<li><a href='http://www.digimantra.com/google/google-chrome-change-default-download-location/' rel='bookmark' title='Permanent Link: Google Chrome : Change default download location'>Google Chrome : Change default download location</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prefix www to your domain using htaccess</title>
		<link>http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/</link>
		<comments>http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 18:47:27 +0000</pubDate>
		<dc:creator>Sachin Khosla</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.digimantra.com/?p=578</guid>
		<description><![CDATA[First of all you need to know why you even want to prefix www in front of your domain. Well to explain in short, search engines treat http://www.digimantra.com/tools/twitter/ and http://digimantra.com/tools/twitter/ differently. Notice the difference is just of www. But  if you have these two URLs distributed all over the web, then search engines may treat [...]


Related posts:<ol><li><a href='http://www.digimantra.com/tutorials/wordpress/moving-your-wordpress-blog-from-one-domain-to-other/' rel='bookmark' title='Permanent Link: Moving your wordpress blog from one domain to other'>Moving your wordpress blog from one domain to other</a></li>
<li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
<li><a href='http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/' rel='bookmark' title='Permanent Link: Advanced htaccess for more than 10 group of backtrack references'>Advanced htaccess for more than 10 group of backtrack references</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>First of all you need to know why you even want to prefix www in front of your domain. Well to explain in short, search engines treat <strong>http://www.digimantra.com/tools/twitter/ </strong> and <strong>http://digimantra.com/tools/twitter/</strong> differently. Notice the difference is just of www. But  if you have these two URLs distributed all over the web, then search engines may treat your content as duplicate. So to avoid duplication of content we redirect the users and search engines to the prefered domain just like I chose www over http://digimantra.com. While redirecting we also need to send a redirect code 301 so that the search engines update their indexes ASAP.</p>
<p>Well the theory part is over and here is the code which you need to copy paste to the .<strong>htaccess</strong> file which should be present in your root folder. This rule is independent of any sorta wordpress or CMS install. But please make sure you make the changes after taking backup, because if you set wrong rules or conditions in .htaccess then you may end up messing up your site&#8217;s URL structures and hence loss of visitors.</p>
<p><span style="color: #008000;"><strong>Code to be copied when your prefered domain is http://www.domain.com</strong></span></p>
<blockquote><p>RewriteEngine On<br />
RewriteCond %{http_host} ^domain.com [NC]<br />
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]</p></blockquote>
<p><span style="color: #008000;"><strong>Code to be copied when your prefered domain is http://domain.com</strong></span></p>
<blockquote><p>RewriteEngine on<br />
RewriteCond %{HTTP_HOST} .<br />
RewriteCond %{HTTP_HOST} !^domain\.com<br />
RewriteRule (.*) http://domain.com/$1 [R=301, L]</p></blockquote>
<p>Hope this helps anyone, there is also a PHP solution available, its easy but I really do not want visitors to go for it, but still in case you do not have access to .htaccess or something, lemme know i can write it down in comment later.. </p>
<p>Cheers!!<br />
Sachin Khosla</p>


<p>Related posts:<ol><li><a href='http://www.digimantra.com/tutorials/wordpress/moving-your-wordpress-blog-from-one-domain-to-other/' rel='bookmark' title='Permanent Link: Moving your wordpress blog from one domain to other'>Moving your wordpress blog from one domain to other</a></li>
<li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
<li><a href='http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/' rel='bookmark' title='Permanent Link: Advanced htaccess for more than 10 group of backtrack references'>Advanced htaccess for more than 10 group of backtrack references</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Advanced htaccess for more than 10 group of backtrack references</title>
		<link>http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/</link>
		<comments>http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/#comments</comments>
		<pubDate>Fri, 01 May 2009 16:23:08 +0000</pubDate>
		<dc:creator>Sachin Khosla</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://realin.co.in/?p=409</guid>
		<description><![CDATA[You  might have faced error where .htaccess wont recognize the backtrack variable after $9 such that if you specify &#8220;$10&#8243; then it will return you &#8220;0&#8243; as value to that key in URL param. The mod_rewrite module is confused which varible to return $1 or $o. Lets see the problem first, Problem : RewriteRule ^tools/chart(/id_([^\/]+))?(/user_([A-Za-z0-9_]+))?(/action_([A-Za-z0-9_]+))?(/date_([A-Za-z0-9_]+))?(/service_([A-Za-z0-9_]+))?(/.+)$ [...]


Related posts:<ol><li><a href='http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/' rel='bookmark' title='Permanent Link: Prefix www to your domain using htaccess'>Prefix www to your domain using htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>You  might have faced error where .htaccess wont recognize the backtrack variable after $9 such that if you specify &#8220;$10&#8243; then it will return you &#8220;0&#8243; as value to that key in URL param. The mod_rewrite module is confused which varible to return $1 or $o. Lets see the problem first,</p>
<p><span style="color: #ff0000;"><strong>Problem :<br />
</strong></span></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteRule</span> ^tools/chart(/id_([^\/]+))?(/user_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/action_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/date_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/service_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/.+)$ my_php_file.php?id=$<span style="color: #ff0000;">2</span>&amp;user=$<span style="color: #ff0000;">4</span>&amp;action=$<span style="color: #ff0000;">6</span>&amp;date=$<span style="color: #ff0000;">8</span>&amp;service=$<span style="color: #ff0000;">10</span>&amp;message=$<span style="color: #ff0000;">12</span></pre></div></div>

<p><span style="color: #ff0000;"><span style="color: #000000;"><br />
<a rel="nofollow" target="_blank" rel="nofollow" href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule " target="_blank">Apache&#8217;s official website says:</a><br />
<strong>Back-references are identifiers of the form $N (N=0..9), which will be replaced by the contents of the Nth group of the matched Pattern.</strong><br />
In the above RewriteRule, the variables $10 and $11 will return 0 and 1 as values respectively. Now let us look at the workaround to this probelm.</span></span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;"><strong><span style="color: #339966;">Solution :</span></strong><br />
</span></span></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} /(service_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/.+)$
<span style="color: #00007f;">RewriteRule</span> ^tools/chart(/id_([^\/]+))?(/user_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/action_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/date_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/service_([A-Za-z0-<span style="color: #ff0000;">9</span>_]+))?(/.+)$ my_php_file.php?id=$<span style="color: #ff0000;">2</span>&amp;user=$<span style="color: #ff0000;">4</span>&amp;action=$<span style="color: #ff0000;">6</span>&amp;date=$<span style="color: #ff0000;">8</span>&amp;service=%2&amp;message=%3</pre></div></div>

<p><span style="color: #ff0000;"><span style="color: #000000;">Using the above RewriteCond and RewriteRule we can grab the values of the group after 9. </span></span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;">Hope this helps <img src='http://www.digimantra.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Advanced htaccess for more than 10 group of backtrack references" /> </span></span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;">Cheers!!<br />
Realin !<br />
</span></span></p>


<p>Related posts:<ol><li><a href='http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/' rel='bookmark' title='Permanent Link: Prefix www to your domain using htaccess'>Prefix www to your domain using htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using .htaccess for day to day work &#124; Part 2</title>
		<link>http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/</link>
		<comments>http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 10:39:43 +0000</pubDate>
		<dc:creator>Sachin Khosla</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://realin.co.in/?p=95</guid>
		<description><![CDATA[This .htaccess is continuation to my previous blog post(Using .htaccess for day to day work), which recorded a lot more hits than expected. I would enlist some other tricks/function we can achieve using this magic .htaccess file. For those who are reading this tutorial for the first time or are new to .htaccess are suggested [...]


Related posts:<ol><li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work'>Using .htaccess for day to day work</a></li>
<li><a href='http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/' rel='bookmark' title='Permanent Link: Prefix www to your domain using htaccess'>Prefix www to your domain using htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This .htaccess is continuation to my previous blog post(<a rel="nofollow" target="_blank" rel="bookmark" href="../2008/10/using-htaccess-for-day-to-day-work/" target="_blank">Using .htaccess for day to day work)</a>, which recorded a lot more hits than expected. I would enlist some other tricks/function we can achieve using this magic .htaccess file. For those who are reading this tutorial for the first time or are new to .htaccess are suggested to <a rel="nofollow" target="_blank" href="http://www.digimantra.com/2008/10/using-htaccess-for-day-to-day-work/" target="_blank">read the main tutorial </a>to know what <a href="http://httpd.apache.org/docs/1.3/howto/htaccess.html" target="_blank">.htaccess</a> is ?</p>
<h3><strong>Handling Document process errors</strong></h3>
<p>There are many times, when a bad request is sent to the server by the client and user is sent <strong>404 page not found</strong> code as a response. Being a webmaster, you would like to retain your user on your site and show him the correct way by suggesting him search page or a customized error page. You can redirect your user to different pages according to different error codes. For example the following code</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">ErrorDocument 404 /errors/custom_error.html</pre></div></div>

<h3><strong>Adding Mime Types to your server</strong></h3>
<p><span id="more-95"></span></p>
<p>There are times when your server doesnt support certain mime types. This happens especially in case of mp3,swf etc. You can do so by adding this line to ur .htaccess file.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">AddType application/x-shockwave-flash swf</pre></div></div>

<p><strong>AddType </strong>is specifying that you are adding a MIME type.        The <strong>application</strong> string is the actual parameter of the        MIME you are adding, and the final little bit is the default extension for        the MIME type you just added, in our example this is <strong>swf</strong> for ShockWave File.</p>
<p>There is a neat trick here, to force a file to        be downloaded, via the Save As browser feature. You can simply set a MIME        type to <strong>application/octet-stream</strong> and that immediately        prompts you for the download.</p>
<h3><strong>Hot Link Protection</strong></h3>
<p>Protecting bandwidth of your server and resources like images is a real pain at times. There are lots of sites which link up images used on your site to theirs. To protect against such theft, you put the following code into your .htaccess. You need to change domain.com to your actual domain.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
RewriteRule \.(gif|jpg|js|css)$ - [F]</pre></div></div>

<p>Put this code into .htaccess present at root or any subdirectory. This will protect the images of type gif and jpg where as javascript files and CSS as well.</p>
<p>Will write up few more tweaks, keep reading</p>
<p>Cheers !!</p>
<p>Realin !</p>


<p>Related posts:<ol><li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work'>Using .htaccess for day to day work</a></li>
<li><a href='http://www.digimantra.com/technology/apache/prefix-www-domain-htaccess/' rel='bookmark' title='Permanent Link: Prefix www to your domain using htaccess'>Prefix www to your domain using htaccess</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using .htaccess for day to day work</title>
		<link>http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/</link>
		<comments>http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 15:59:48 +0000</pubDate>
		<dc:creator>Sachin Khosla</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://realin.co.in/?p=85</guid>
		<description><![CDATA[.htaccess is a word which every developer has heard. But they skip it because some think its too hard to understand. But I am sure nothing is hard for a good programmer. Well .htaccess is a file which is used to define behaviour of your directories and server request to those directories or files. This [...]


Related posts:<ol><li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
<li><a href='http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/' rel='bookmark' title='Permanent Link: Advanced htaccess for more than 10 group of backtrack references'>Advanced htaccess for more than 10 group of backtrack references</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a rel="nofollow" target="_blank" href="http://httpd.apache.org/docs/1.3/howto/htaccess.html" target="_blank">.htaccess</a> is a word which every developer has heard. But they skip it because some think its too hard to understand. But I am sure nothing is hard for a good programmer. Well .htaccess is a file which is used to define behaviour of your directories and server request to those directories or files. This file is supported by <a rel="nofollow" target="_blank" href="http://www.apache.org" target="_blank">apache</a> and not IIS. This is an ASCII file and should be uploaded to the server using ASCII mode and not binary.</p>
<h3><strong>Workarea for .htaccess</strong></h3>
<p>If we place .htaccess file into the root of our website then all the folder and subfolders will be affected by the rules written in it. But if the subfolder or folders have their own .htaccess file (may be empty) then the first preference is given to it. So the preference is for the nearest .htaccess file.</p>
<p>I will now list some of the basic .htaccess techniques which can be used to makea programmer&#8217;s life easy.</p>
<h3><strong>Redirect Url</strong></h3>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">Redirect /mydir/oldfile.html http://mydomain.com/newdir/newfile.html</pre></div></div>

<h3><strong>Stop Indexing a directory</strong></h3>
<p>Yes this is one the tedious task which every programmer has to do. So that the file are not indexed when a directory may get called from browsers. A simple one line rule can make your life easy.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">Options -Indexes</pre></div></div>

<p><span id="more-85"></span></p>
<h3>Chanding the index page of the directory</h3>
<p>We all know that by default Apache looks for the file <strong>index.html</strong> in a directory when it gets a request from the client. What if we want to change the index file, i may want my index.php to be parsed and send to the client as a response. Then i can simply write the following rule in .htaccess</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">DirectoryIndex index.php index.html</pre></div></div>

<p>The priority decreases from left to right</p>
<h3><strong>Adding SSI Support to the server</strong></h3>
<p>Many people want to use SSI (Server Side Includes) but their web hosting providers doesn&#8217;t seem to give support on that. Well no worries, .htaccess have got an answer for the desperadoes <img src='http://www.digimantra.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Using .htaccess for day to day work" /> </p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&nbsp;
AddType text/html shtml
&nbsp;
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
&nbsp;
you may also want to change the default index file, this can be done using
&nbsp;
DirectoryIndex index.shtml index.html</pre></div></div>

<p>A quick explanation would be, that the <strong>first line</strong> adds the type of extension and <strong>second line</strong> ask the file of the type shtml to be parsed on the server side. <strong>Third line</strong> is not always mandatory as long as your server has enabled it. FolloWSymLinks is basically tells apache to follow the real file if it finds a link to the real file in the specified directory.</p>
<h3><strong>Block Users based on IP address</strong></h3>
<p>There are times when you want to block certain users or certain range of IP address to be blocked, so that they cannot access your website or pages/dirs/. This can be done using the following code.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&nbsp;
order allow,deny
&nbsp;
deny from 122.123.111.34
&nbsp;
deny from 122.123.111.23
&nbsp;
allow from all</pre></div></div>

<p>The <strong>First Line</strong> defines the three phase parsing of apache. It is not necessary to define this here but still a quick definition would be , order allows to parse the allow directives first then deny conditions and then the conditions which do not match both of them and then sends back the response to the client. <strong>Second line </strong>denies the access from the given IP, <strong>Third line </strong>is similar to second, while <strong>fourth line </strong>allows everyone else to access.</p>
<p>We could also write</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"> deny from all</pre></div></div>

<p> to block everyone to access the given directory on apache.</p>
<p>Well guys, will write more of these snippets very soon.</p>
<p>Gotta go now <img src='http://www.digimantra.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="Using .htaccess for day to day work" /> </p>
<p>Cheers !!</p>
<p>Realin !</p>


<p>Related posts:<ol><li><a href='http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work-part-2/' rel='bookmark' title='Permanent Link: Using .htaccess for day to day work | Part 2'>Using .htaccess for day to day work | Part 2</a></li>
<li><a href='http://www.digimantra.com/technology/apache/change-default-phpini-values-htaccess/' rel='bookmark' title='Permanent Link: Change default php.ini values using .htaccess'>Change default php.ini values using .htaccess</a></li>
<li><a href='http://www.digimantra.com/tutorials/advanced-htaccess-for-more-than-10-group-of-backtrack-references/' rel='bookmark' title='Permanent Link: Advanced htaccess for more than 10 group of backtrack references'>Advanced htaccess for more than 10 group of backtrack references</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.digimantra.com/technology/using-htaccess-for-day-to-day-work/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
