<?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>Penguin on Rails &#187; Nginx</title>
	<atom:link href="http://www.cherpec.com/category/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cherpec.com</link>
	<description>linux + ruby on rails = love</description>
	<lastBuildDate>Thu, 17 Jun 2010 14:06:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Redirect to www.domain.com with Nginx</title>
		<link>http://www.cherpec.com/2008/07/redirect-to-www-domain-com-with-nginx/</link>
		<comments>http://www.cherpec.com/2008/07/redirect-to-www-domain-com-with-nginx/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 18:25:28 +0000</pubDate>
		<dc:creator>Vitalie Cherpec</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[permanent]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.cherpec.com/?p=11</guid>
		<description><![CDATA[Depending on your requirements you&#8217;ll need to redirect your users from domain.com to www.domain.com with a permanent redirect in order to improve your site SEO ranking. We already know how to do it with apache and mod_rewrite, but how do you make it in nginx ? It&#8217;s not too hard.
Apache configuration:

#.htaccess
RewriteEngine On
RewriteCond %&#123;HTTP_HOST&#125; !^www\.domain\.com
RewriteRule &#40;.*&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>Depending on your requirements you&#8217;ll need to redirect your users from <strong>domain.com</strong> to <strong>www.domain.com</strong> with a permanent redirect in order to improve your site SEO ranking. We already know how to do it with apache and mod_rewrite, but how do you make it in nginx ? It&#8217;s not too hard.</p>
<p>Apache configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#.htaccess</span>
RewriteEngine On
RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_HOST<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>^www\.domain\.com
RewriteRule <span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.domain.com$<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">R</span>=<span style="color: #000000;">301</span>,L<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Nginx configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/nginx/nginx.conf</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$http_host</span> <span style="color: #000000; font-weight: bold;">!</span>~ <span style="color: #ff0000;">&quot;^www\.domain\.com$&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    rewrite  ^<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>    http:<span style="color: #000000; font-weight: bold;">//</span>www.domain.com$<span style="color: #000000;">1</span> permanent;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.cherpec.com/2008/07/redirect-to-www-domain-com-with-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
