<?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>Tara Andrei &#187; apache</title>
	<atom:link href="http://andreitara.com/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://andreitara.com</link>
	<description>I could change the world if they would let my allocate more instances of myself.</description>
	<lastBuildDate>Mon, 13 Jun 2011 21:32:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>The magic of mode_rewrite</title>
		<link>http://andreitara.com/2010/06/the-magic-of-mode_rewrite/</link>
		<comments>http://andreitara.com/2010/06/the-magic-of-mode_rewrite/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 20:00:35 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[others]]></category>
		<category><![CDATA[Programare]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web app]]></category>
		<category><![CDATA[apache mode_rewrite]]></category>
		<category><![CDATA[installing mode_rewrite on linux]]></category>
		<category><![CDATA[installing mode_rewrite on windows]]></category>

		<guid isPermaLink="false">http://www.andreitara.com/?p=244</guid>
		<description><![CDATA[There&#8217;s a long time in the galaxy since I haven&#8217;t post on my blog and now,  finally here I am, posing a new article. Today I will speak about htaccess mod_rewrite. Well despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo. The majority of the web servers, that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.andreitara.com/wp-content/uploads/2010/06/images.jpg"><img class="alignleft size-full wp-image-252" title="images" src="http://www.andreitara.com/wp-content/uploads/2010/06/images.jpg" alt="images" width="179" height="134" /></a>There&#8217;s a long time in the galaxy since I haven&#8217;t post on my blog and now,  finally here I am, posing a new article. Today I will speak about <a title=".Htaccess rewrites, Mod_Rewrite Tricks and Tips" href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html">htaccess mod_rewrite</a>. Well despite the tons of examples and docs, <strong>mod_rewrite</strong> is voodoo. Damned cool voodoo, but still voodoo.</p>
<p>The majority of the web servers, that are based on Apache, have the mod_rewrite enabled so you don&#8217;t have to get dirty to install it on the hosting server.But anyone of those that are developing web application based on Apache server,  using PHP have a local installed server therefore mode_rewrite is also  necessary in testing process.<br />
<span id="more-244"></span></p>
<p>Installing mod_rewrite :</p>
<ol>
<li>On Linux: edit the Apache configuration file (  httpd.conf ) and uncomment   <em>LoadModule rewrite_module modules/mod_rewrite.so</em> (remove the  pound &#8216;#&#8217; sign from in front of the line) . Also be sure that the lines containing <em>ClearModuleList</em> and <em>AddModule mod_rewrite.c are</em> uncommented . Now you can create the famous .htacess file on the root of you website and start adding your code.</li>
<li>On Windows: well as we are expecting, things are a bit more complicated because on Windows you cannot create a file that doesn&#8217;t have a name (.htacess is a file that only have an extension). For first just uncomment the same lines as in the Linux example. Now you have to tell Apache to use you&#8217;re custom file instead of  .htacess file, so search in the configuration file (httpd.conf)  for the following lines:</li>
</ol>
<p style="padding-left: 60px;"><strong># AccessFileName: The  name of the file to look for in each directory # for additional  configuration directives. See also the AllowOverride<br />
# directive.<br />
#<br />
AccessFileName .htaccess (change the .htaccess to [name].htaccess where name can be whatever what you wish )</strong></p>
<p style="padding-left: 30px;">You can escape this step and create the .htacess file even on windows, actually the restriction of creating a file without name is an restriction of Windows Explorer is not an restriction of the operating system<strong> </strong>. Open the command (cmd), go to the root folder of the website and type <strong>copy con .htacess </strong>and press <strong>Ctrl+Z</strong>. well&#8230; that&#8217;s all folks.</p>
<p>Maybe you are asking yourself  about mod_rewrite and where to use it, well the short and  simple answer is :  for simplifying the URL of a website, simpler/shorter URL are easier to write easier to remember. For example instead of having an URL  like this www.example.com?id_product=23123&amp;color=23 you can have something like www.example.com/iphone-white. Mod_rewrite basicly make   use of regular expression to rewrite an specified URL.</p>
<p style="padding-left: 30px;">When to use it: mod_rewrite can be used in many circumstances where you may want to rewrite the an URL, also you can create dynamically virtual hosting entry;  practically mode_rewrite is an &#8220;Swiss Army Knife&#8221;.</p>
<p style="padding-left: 30px;">When not to use it: well as I have mentioned  before mode_rewrite make use of regular expression, and evaluating regular expression takes time, use memory and the global performance of the server is decreasing.</p>
<p>I will provide you some basic example of using mode_rewrite. .htaccess file should begin with:</p>
<pre style="padding-left: 60px;"><strong>Options +FollowSymLinks
RewriteEngine On
RewriteBase /

</strong></pre>
<ol>
<li><span style="text-decoration: underline;">Redirecting</span> <strong> </strong><br />
<strong>Redirect /index.php   http://www.example.com</strong>/    -this example redirect the current site to www.example.com<br />
RedirectMatch (.*)\.gif http://images.example.com$1.png      -In this example, we’ve taken all of our GIF files, converted them to PNG files, and<br />
moved them to another server</li>
<li><span style="text-decoration: underline;">Require www</span>
<pre>Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]</pre>
</li>
<li>Denying access to a folder except of fopen file from php
<pre>RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]
RewriteRule .* - [F,L]</pre>
</li>
<li>Limit access during some hours
<pre class="odd">Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# If the hour is 7
RewriteCond %{TIME_HOUR} ^7$
RewriteRule ^.*$ - [F,L]</pre>
</li>
</ol>
<p>These samples are here just to open your appetite for mode_rewrite. Practically this tool can be used in any other ways,yes&#8230; the limit is your imagination.</p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2010/06/the-magic-of-mode_rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

