<?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>VV&#039;s Corner &#187; mod_rewrite</title>
	<atom:link href="http://vinoaj.com/blog/category/howtos/apache/mod_rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://vinoaj.com/blog</link>
	<description>my collection of random thoughts, how-to&#039;s and code snippets</description>
	<lastBuildDate>Sat, 04 Dec 2010 15:05:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Rewriting URLs to force www or non-www URLs</title>
		<link>http://vinoaj.com/blog/2007/04/rewriting-urls-to-force-www-or-non-www-urls/</link>
		<comments>http://vinoaj.com/blog/2007/04/rewriting-urls-to-force-www-or-non-www-urls/#comments</comments>
		<pubDate>Thu, 12 Apr 2007 21:25:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://vinoaj.com/blog/uncategorized/rewriting-urls-to-force-www-or-non-www-urls/</guid>
		<description><![CDATA[PLAIN TEXT CODE: #Activate the rewrite engine if it isn't so already RewriteEngine on #intercept all HTTP requests to the site that do not have a 'www.' at the beginning of the Domain name #and then force a redirect to the same page address only this time, including the 'www.' RewriteCond %{HTTP_HOST} !^www\..* [NC] RewriteRule [...]]]></description>
			<content:encoded><![CDATA[<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showPlainTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#Activate the rewrite engine if it isn<span style="color:#CC0000;">'t so already</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">RewriteEngine on</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"></li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">#intercept all HTTP requests to the site that do not have a '</span>www.<span style="color:#CC0000;">' at the beginning of the Domain name</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">#and then force a redirect to the same page address only this time, including the '</span>www.<span style="color:#CC0000;">'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">RewriteCond %{HTTP_HOST} !^www<span style="color:#000099; font-weight:bold;">\.</span>.* [NC]</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]</span></div>
</li>
<li style="font-weight: bold;color:#26536A;"></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">#The inverse of the above rule - intercept HTTP requests with a '</span>www.<span style="color:#CC0000;">' at the start and redirect to the non-www version</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;"># Ensure that your serverName directive is set up to the non-www name of your domain</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">RewriteCond %{HTTP_HOST} ^www<span style="color:#000099; font-weight:bold;">\.</span>.* [NC]</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">RewriteRule ^(.*) http://%{SERVER_NAME}/$1 [R=301] </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://vinoaj.com/blog/2007/04/rewriting-urls-to-force-www-or-non-www-urls/&via=vinoaj&text=Rewriting URLs to force www or non-www URLs&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://vinoaj.com/blog/2007/04/rewriting-urls-to-force-www-or-non-www-urls/&via=vinoaj&text=Rewriting URLs to force www or non-www URLs&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://vinoaj.com/blog/2007/04/rewriting-urls-to-force-www-or-non-www-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

