<?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>iandouglas.com &#187; mod_rewrite</title>
	<atom:link href="http://iandouglas.com/tag/mod_rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://iandouglas.com</link>
	<description>senior web architect</description>
	<lastBuildDate>Thu, 10 Jun 2010 17:58:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>HOWTO: redirect iPhone/iPod users on nginx</title>
		<link>http://iandouglas.com/2010/01/20/howto-redirect-iphoneipod-users-on-nginx/</link>
		<comments>http://iandouglas.com/2010/01/20/howto-redirect-iphoneipod-users-on-nginx/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 23:44:46 +0000</pubDate>
		<dc:creator>id</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://iandouglas.com/?p=35</guid>
		<description><![CDATA[I learned a little something about nginx, a small footprint web server that is ideal for serving up mobile sites, or sites where you don&#8217;t want the heavy usage of Apache. Today, I needed to solve a problem where we redirected iPhone/iPod users to a different URL. Since nginx doesn&#8217;t use the old-style mod_rewrite rules, [...]]]></description>
			<content:encoded><![CDATA[<p>I learned a little something about nginx, a small footprint web server that is ideal for serving up mobile sites, or sites where you don&#8217;t want the heavy usage of Apache. Today, I needed to solve a problem where we redirected iPhone/iPod users to a different URL. Since nginx doesn&#8217;t use the old-style mod_rewrite rules, I had to learn how to enable redirection in the server.</p>
<p>Since nginx was already compiled with redirection support, I simply had to locate the correct configuration file and add a few lines of code, and away it went.</p>
<p>First, I checked out /etc/nginx/ and opened the site configuration file within the /sites-enabled/ path. For this example, let&#8217;s say the site was m.iandouglas.com:</p>
<pre><code># vi /etc/conf/nginx/sites-enabled/m.iandouglas.com</code></pre>
<p>In here, I&#8217;d look for the &#8216;server&#8217; block and add my redirection rules:</p>
<pre><code>server {
	listen      80;
	server_name m.iandouglas.com;
        root /var/www/m.iandouglas.com/public;

	# redirect iPhone/iPod users to the new iphone site
        if ($http_user_agent ~* '(iPhone|iPod)') {
                rewrite ^/$ http://m.iandouglas.com/iphone/index.html;
        }
.
.
.
</code></pre>
<p>Then a simple nginx restart:</p>
<p><code># /etc/init.d/nginx restart</code></p>
<p>&#8230; and we were all set.</p>
]]></content:encoded>
			<wfw:commentRss>http://iandouglas.com/2010/01/20/howto-redirect-iphoneipod-users-on-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
