<?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>Robertdot, A Web Design Blog &#187; mod_rewrite</title>
	<atom:link href="http://robertdot.org/tags/mod_rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertdot.org</link>
	<description>A web design blog for designers that develop or developers that design.</description>
	<lastBuildDate>Tue, 25 Jan 2011 20:43:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>mod_rewrite example</title>
		<link>http://robertdot.org/2005/06/27/mod_rewrite-example/</link>
		<comments>http://robertdot.org/2005/06/27/mod_rewrite-example/#comments</comments>
		<pubDate>Mon, 27 Jun 2005 13:16:50 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://robertdot.org/?p=61</guid>
		<description><![CDATA[
This is a port from the old Robertdot.


 At work, we started using a redirect method with mod_rewrite that allowed us to send all file requests to a file called _process_me.php. This gave us tons of flexibility, allowing us to even make pages on the fly. If you can&#8217;t imagine why anyone would do this, [...]]]></description>
			<content:encoded><![CDATA[<p>
<strong>This is a port from the old Robertdot.</strong>
</p>
<p>
 At work, we started using a redirect method with mod_rewrite that allowed us to send all file requests to a file called _process_me.php. This gave us tons of flexibility, allowing us to even make pages on the fly. If you can&#8217;t imagine why anyone would do this, imagine serving a page that doesn&#8217;t exist, assembled completely on the fly, without the user knowing. If you don&#8217;t get it yet, press ALT+F4 or COMMAND-Q right now for more information.
</p>
<p>
 I really wanted to make use of this on my personal site. However, both my Mac and Delta Web Hosting were being major headaches. So, I sat down tonight to figure out what the problem was. Since I didn&#8217;t play with the Apache Configs on either system, it was a bit of a mystery at first. Here is what I came up with (some of the code may have spaces that don&#8217;t need to be there&#8230; my text formatting system misinterprets stuff):
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"> <span style="color: #666666; font-style: italic;"># These are both required!</span>
 Options <span style="color: #339933;">+</span>FollowSymLinks <span style="color: #339933;">-</span>Indexes
&nbsp;
 <span style="color: #666666; font-style: italic;"># Give it a default file for kicks...</span>
 DirectoryIndex <span style="color: #000066;">index</span><span style="color: #339933;">.</span>html
&nbsp;
 RewriteEngine on
&nbsp;
 <span style="color: #666666; font-style: italic;"># Commented one is for live tests...</span>
 <span style="color: #666666; font-style: italic;">#RewriteBase / robertdot_new/</span>
 RewriteBase <span style="color: #339933;">/</span> <span style="color: #339933;">~</span>robert<span style="color: #339933;">/</span>robertdot_new<span style="color: #339933;">/</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Forward blank requests to the default file</span>
 RewriteRule <span style="color: #339933;">^</span>$ <span style="color: #000066;">index</span><span style="color: #339933;">.</span>html
&nbsp;
 <span style="color: #666666; font-style: italic;"># This would forward requests from robertdot.org to www. robertdot .org</span>
 <span style="color: #666666; font-style: italic;">#RewriteCond %{HTTP_HOST} ^robertdot.org$ [NC]</span>
 <span style="color: #666666; font-style: italic;">#RewriteRule ^(.*)$ http: //www .robertdot.org/$1 [R,L]</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># If the filename is not a valid directory, set the redirect flag to true</span>
 RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_FILENAME<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!-</span>d
 RewriteRule <span style="color: #339933;">^.*</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#91;</span>E<span style="color: #339933;">=</span>HTTP_GO<span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># If the filename is not a valid file, set the redirect flag to true</span>
 RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_FILENAME<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!-</span>f
 RewriteRule <span style="color: #339933;">^.*</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#91;</span>E<span style="color: #339933;">=</span>HTTP_GO<span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># If the filename is a valid directory, set the redirect flag to true</span>
 RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_FILENAME<span style="color: #009900;">&#125;</span> <span style="color: #339933;">-</span>d
 RewriteRule <span style="color: #339933;">^.*</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#91;</span>E<span style="color: #339933;">=</span>HTTP_GO<span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Forward everything except _process_me.php to _process_me.php</span>
 RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>ENV<span style="color: #339933;">:</span>HTTP_GO<span style="color: #009900;">&#125;</span> <span style="color: #339933;">^</span><span style="color: #cc66cc;">1</span>$
 RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_FILENAME<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!</span>_process_me<span style="color: #339933;">.</span>php
 RewriteRule <span style="color: #339933;">.</span> _preprocess<span style="color: #339933;">.</span>php</pre></td></tr></table></div>

<p>
 So, for all you kiddies that were looking for mod_rewrite examples, there is a <em>really</em> good one. If you need more explanation of what is happening, just read the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">mod_rewrite documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2005/06/27/mod_rewrite-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

